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

jolly-raincoat-49731

09/14/2023, 8:22 PM
Hello, I've just started using the JS SDK. I have a few questions that I cannot seem to find and/or figure out. 1) Given the initial setup code here, do I create a new instance for every experiment I want to run? 2) How can I target pages specifically based on something in the page? Let's use categories as an example. If the data attribute,
data-category-level
is defined and has a value of
top
? This specific test would only run on top level category pages. 3) Do I need to use
isOn
or
getFeatureValue
to trigger the experiment? In my testing, it seemed the experiment was only viewed when I fired
isOn
for the feature I was using.
b

brief-honey-45610

09/14/2023, 8:42 PM
Hi Erik, welcome to GrowthBook! Thanks for reaching out with these JS SDK questions.
I'll return to answer your questions as soon as I can!
j

jolly-raincoat-49731

09/14/2023, 8:45 PM
Appreciate it, thanks!
b

brief-honey-45610

09/15/2023, 3:55 AM
Hi Erik, I apologize I wasn't able to answer your questions today. Your support request is still on my radar! I'll ask my colleague in Europe to reply when he comes online tomorrow (I'm in the US) but if he is unable to I'll work on this tomorrow morning.
h

happy-autumn-40938

09/15/2023, 4:28 AM
I'll try to answer some of these. 1. A new instance of the SDK per experiment? No, you typically only need one SDK instance to run multiple experiments (of course this may change if you have multiple environments or projects). 2. That's probably best left up to you to rig up using your site code / javascript rather than using GrowthBook targeting attributes. GB attributes are typically used to target specific users (i.e. "US based", "pro members", etc) rather than anything based on the current page being browsed. 3. Yeah, any sort of flag linked to an experiment needs to be evaluated to trigger. IsOn() is one of the ways to do this.
j

jolly-raincoat-49731

09/15/2023, 1:00 PM
Thanks for the responses. We're just getting everything set up and I hadn't seen much for these. I'll probably have some more questions in the very near future (today probably haha).
We're using GA4/BigQuery as our data warehouse. What is the best practice for setting the ID attribute to target users?
What I mean is using the
id
when "Assign variation based on attribute" is used.
h

happy-autumn-40938

09/15/2023, 4:57 PM
I'm not a GA4 expert, but we do have a tutorial for this that is worth a look if you haven't seen it already: https://docs.growthbook.io/guide/GA4-google-analytics
j

jolly-raincoat-49731

09/15/2023, 5:50 PM
Thanks, I'll read those.
8 Views