https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
h

happy-vase-5985

07/18/2022, 11:59 AM
Hello GrowthBook! I'm currently trying a visual experiment that gives me this code sample
Copy code
{
  "mutations": [
    [
      "#__next > div:nth-child(1)",
      "set html",
      "Foo bar version"
    ]
  ],
  "css": ""
}
Where do I need to put it in order to have my experiment displayed in my website?
f

future-teacher-7046

07/18/2022, 12:07 PM
If you go to the settings page, you should see a code snippet for how to load the visual editor on your website
h

happy-vase-5985

07/18/2022, 12:08 PM
So I need to put it in the
Copy code
window.GROWTHBOOK_CONFIG
object?
f

future-teacher-7046

07/18/2022, 12:09 PM
you don't need to put that mutations code anywhere. In the code snippet, it references a javascript file that will already have that code in it
h

happy-vase-5985

07/18/2022, 12:09 PM
Ok! I must have missed something else then 🙂 Thx for your help!
Can you please help make this work @future-teacher-7046? I've followed all the steps and the script seems to be well charged on my page, but I can't see any change
f

future-teacher-7046

07/18/2022, 1:32 PM
Do you see anything in the browser dev tools console on your site?
h

happy-vase-5985

07/18/2022, 1:47 PM
I don't have any error, but I can see objects of different types, with my experiment in it
f

future-teacher-7046

07/18/2022, 1:58 PM
Can you dm me the URL and I can take a look?
h

happy-vase-5985

07/18/2022, 1:59 PM
i'm running it in localhost, maybe the issue comes from this?
FYI my localhost page is well displayed in the visual studio of GrowthBook
f

future-teacher-7046

07/18/2022, 2:01 PM
if it works in the visual editor, then that means the script loaded correctly. It might be a problem with the targeting conditions of the experiment. If the URL doesn't match properly then the test won't run
Or if you are targeting the experiment to logged-in users, but your GROWTHBOOK_CONFIG doesn't have a
userId
set.
h

happy-vase-5985

07/18/2022, 2:22 PM
It's working! I miss-understood
the experiment "tracking key"
from your doc to pass as URL param I was passing
register_button
instead of
register-button
because here
Copy code
const growthbook = new GrowthBook({
    trackingCallback: (experiment, result) => {
      console.log({
        experimentId: experiment.key, 
        variationId: result.variationId
      })
    }
  });
experimentId: "register_button"
😅
8 Views