Hi team! I’m trying to run a test and I’m getting ...
# ask-questions
s
Hi team! I’m trying to run a test and I’m getting a little lost in some of the details. I’d very much appreciate a nudge in the right direction! Context: • GA4 events with BigQuery integration which I have up as a data source • JavaScript SDK with a React application • I am working with anonymous users, so I want to use the
anonymous_id
attribute • I have set up some custom GA4 events already as metrics • I watched "Migrating from Google Optimize" and "Feature flagging and A/B testing with NextJS and GrowthBook” Questions: 1. ID Attribute: I assume I want to do
growthbook.setAttributes({ id: anonymous_id })
— is there a guide or info on how to access the anonymous_id from GA4 so I can pass it through? 2. Tracking Key: in "Experiment Settings" this says, “Unique identifier for this experiment, used to track impressions and analyze results. Will match against the experiment_id column in your data source.” Is there info on how to set an "experiment_id" column in GA4 events and is it supposed to appear on both the activation metric and the goal metrics? 3. Activation Metric: I was pretty confused by the
trackingCallback
in the demos examples, but I’m seeing now that it should trigger this metric. Is there an example of what a GA4 event usually looks like for that and is that where the
experiment_id
column gets picked up?
f
Hi @salmon-policeman-87046 the tracking-key I use it as a experiment ID. To your questions: 1. You need to write your own code so the anon ID is set in the growthbook UserID attribute. Usually you have to also check on about Cookie consent etc. but It might not sound sexy but a polling technique to check for the GA anon ID works fine also from performance perspective. _ga is the name of the cookie you are looking for. 2. When the trackingCallback fires (happens automatically when an experiment is launched) the growthbook will do a datalayer push which contains the tracking-key and the variation id. Then you would need a GTM tag that retrieves this from the datalayer and sends it to GA4. 3. See attachement
🙌 1
Here is the datalayer example… note we changed the event name… so normally I think it’s called viewed_experiment.
@salmon-policeman-87046 correction: epxeriment_viewed