Link here.
<script>
dataLayer = [];
</script>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" // disguised GTM snippet
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PB4S9P');</script>
<!-- End Google Tag Manager -->
<script>
dataLayer.push({
'event':'nevent',
'eventCategory': 'form submissions',
'eventAction': 'saw form',
'eventLabel': '[GPI - Donation Request Form]' // e.g. Newsletter signup form - NEW SITE
});
</script>
When I visit the link and open the console and type dataLayer I expected to see the object. But I cannot.
When I am on the page if I cut n paste the dataLayer.push({}); it works - I see it added to the dataLayer.
So how could it be that the dataLayer array is not populated with the contents of the push below it?
dataLayerinto the console. I get the object.dataLayervariable. Try putting it inside some variant of document.ready