I'm having problems with experiment_viewed not bei...
# ask-questions
r
I'm having problems with experiment_viewed not being sent to GA HTML script. I can trigger an experiment, and the experiment event data is pushed to the datalayer (see screenshot). But no hit is sent to GA. I tried setting up the tags, variables etc in GTM, but then I instead got double hits to GA.. (4 events in GTM debugger, whereas 2 include hits to GA, both with gtag api call - but only one hit includes variation and experiment IDs) I had an hypothesis of the script being loaded before gtag in the head, and a developer helped me setup a rule to wait until head is stable. Still doesn't work. I've tried the documentation, forums etc but can't find the solution.
s
It's not clear from your description what could be happening. Are you using GTM to load GA 4? I know you said you checked the docs, but I'd make sure that your GTM config matches what's listed here: https://docs.growthbook.io/guide/google-tag-manager-and-growthbook
r
hi @strong-mouse-55694, so we are using the html script directly in head. GA4 runs through GTM. when an experiment is launched I see 2 datalayer pushes with the experiment info, one gtag and one "general datalayer". But no hit is sent to GA. I figured it has something to do with timing, but now it's solved setting a tracking callback in the html script and then send events to GA using GTM. So, probably not the best practice solution but atleast i'm sending events to GA4 now
s
Gotcha. You're probably right that it's a timing issue. The script tag will fire events for GA4 and GTM automatically, so that's why you could've seen dupes. You could try loading GrowthBook via GTM to help with timing (but that might introduce other complexity). Your solution makes sense.
1
r
while I have you here: now im stuck in the next problem 😄 when using anonymous_id as my identifier (i assume gbuuid) when i run an experiment and enter the site without having accepted cookies, i'm assigned to a variant, i see the hashing id comes from session storage. but, when i accept cookies and reload the page or go to another page, the hashing id is changed, probably fetching the gbuuid from the gb cookie. So the problem is that the id used to assign users to variations when entering the site does not persist when cookies are accepted I'm having a hard time finding solutions, but found one in the community suggesting to store the temporary id (when entering the site) and make sure it persists when the cookie is accepted. Would you say this is the only reasonable solution or are there others?
s
I think I'd need a bit more info on how you're initializing GrowthBook and how you're handling cookies more generally. However, this info might answer your question, too: https://docs.growthbook.io/lib/script-tag#cookie-policy-and-gdpr
r
I continued the dialog in pm, sharing the summary: • my problem is that the gbuuid cookie is somehow deleted (might be by the cookie management tool) before consent • every reload without consent gives a new hashing id, leading to rebucketing • after consent and reload, the gbuuid cookie appears with a new id which makes growthbook rebucket the users, this time in a persistent manner since the cookie is set and the id is stored properly proposed solutions are 1. check the cookie management tool to allow gbuuid cookie 2. use the temporary id (from session storage) to store locally until consent is on and the stable id is set in gbuuid cookie will try these solutions tomorrow