Struggling with Growth 2.9s 'New HTML Script Tag S...
# ask-questions
p
Struggling with Growth 2.9s 'New HTML Script Tag SDK' and google tag manager The documentation in these 2 locations: • https://docs.growthbook.io/lib/script-tag#google-tag-managerhttps://docs.growthbook.io/guide/google-tag-manager-and-growthbook#tracking-via-datalayer-and-gtm Suggests the tag will notify the data layer like this (the correct way)
Copy code
window.dataLayer.push({
    'event': 'experiment_viewed',
    'experiment_id': experiment.key,
    'variation_id': result.key
  });
But it appears to send the data like this:
Copy code
window.dataLayer.push(["event", "experiment_viewed", n]),
The end result is that the trigger documented here will never fire: • https://docs.growthbook.io/guide/google-tag-manager-and-growthbook#step-4-add-a-trigger Does anyone have experience with google tag manager triggers working against the new tag? have i missed something here? I imagine i'm going to have to ignore the default attempt to add to data layer and do it myself via custom tracking callback: https://docs.growthbook.io/lib/script-tag#others
f
Hi Darren - where do you see it pushing an array to the dataLayer?
p
Hi @fresh-football-47124 no worries, please go here and enter dataLayer into console https://www.addtoevent.co.uk/listings/confetti/west-yorkshire/leeds
Implementation
<script data-client-key="XXXXXXXXXXX" src="<https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js>" async="async"></script>
Potentially this is the issue from auto.min.js
Copy code
// GA4 (gtag and GTM options)
      window.gtag ? window.gtag("event", "experiment_viewed", p) : window.dataLayer && window.dataLayer.push({
        event: "experiment_viewed",
        ...p
      });
It's assuming that if gtag is present that's used and array sent instead of object via google tag manager think panic
That could be clearer in documentation for newer users, but I think ideally that's a preference you should be able to set potentially.
As mentioned in my original message for now i've added and have had success adding this before my auto.min.js implementation:
Copy code
<script>
window.growthbook_config = window.growthbook_config || {};
window.growthbook_config.trackingCallback = (experiment, result) => {
          dataLayer.push({
            'event': 'experiment_viewed',
            'experiment_id': experiment.key,
            'variation_id': result.variationId
          });
};
</script>
My Ga4 configuration is implemented via a google tag if that helps