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

glamorous-keyboard-76926

11/22/2023, 10:13 PM
Would someone be able to evaluate if this code is acceptable or if any modifications are needed? This was generated by AI and is meant to be my initialization code for Google Tag Manager. The Growbook SDK code will be in a separate tag and 1st in the tag firing sequence. Since it’s AI-generated, I’m wanting to get a second pair of eyes on it and make sure I’m following best practices as the GTM installation instructions aren’t geared towards a less tech-savvy, DIY marketer like myself. Thanks in advance! Edit: The Google Tag is set up separately in GTM to fire on initialization. The trigger for both growthbook tags would be a pageview which occurs after initialization. I’m using growthbook connected to bigquery, connected to GA4.
h

happy-autumn-40938

11/22/2023, 10:56 PM
hard to say. Looks kind of like the GTM sample code I wrote for our GTM tutorial. At minimum, your <script> tag is missing the
id="growthbook-sdk"
attribute at the top of your snippet. Devil's in the details though especially with async loading using GTM...
g

glamorous-keyboard-76926

11/22/2023, 11:02 PM
To give you some context, I’ll attach the prompt I used to give me this output and it’s based on the growthbook GTM tutorial if that’s the one you’re referring to. I struggled to fully understand what I needed to do since I come from a marketing background and never touch code. In my first screenshot, on which line should I add
id="growthbook-sdk"
?
h

happy-autumn-40938

11/22/2023, 11:03 PM
oh I see, you've got the id in the other <script> tag which actually loads the .js file. That will probably work...
You can try it and see what happens. If you grab our devtools Chrome extension, it should help you verify that the SDK is successfully set up and triggering features/experiments
g

glamorous-keyboard-76926

11/22/2023, 11:05 PM
Thanks for that tip! I’ll likely publish it next week when I have some backup just in case. I have downloaded the extension so I’ll make sure to use that also.
3 Views