This message was deleted.
# ask-questions
w
This message was deleted.
s
Can you share the GTM tag code?
d
<script async data-api-host="https://cdn.growthbook.io" data-client-key="sdk-gne8v9YSAltG8it3" src="https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js"
</script>
Here you go! Thank you for your help.
s
So, this won't work in GTM, as it strips out data attributes for security reasons. Our docs cover how to do this, but here's what you need to do:
Copy code
<script>
(function(s) {
  s=document.createElement('script'); s.async=true;
  s.dataset.clientKey="YOUR_CLIENT_KEY_HERE";
  s.src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js>";
  document.head.appendChild(s);
})();
</script>
https://docs.growthbook.io/guide/google-tag-manager-and-growthbook#creating-a-gtm-tag-for-the-growthbook-sdk
d
thank you! very strange it has worked in gtm preview the first time as the expirement_viewed event was firing before. Either way, there's a strange behaviour in the dataLayer. the expirement_viewed event only fires after interaction with the site (click or scroll). the SDK is firing at event #9 consent_status. Before the experiment_viewed event is firing, the variable for the feature value stays undefined. JS to get the variable: function() { if (window._growthbook && window._growthbook.getFeatureValue) { return window._growthbook.getFeatureValue("trust_widget"); } return undefined; }
@strong-mouse-55694 is there anything wrong with the implementation or is this behaviour normal?
116 Views