GTM snippet put after the GAnalytics one:
<!-- Google Tag Manager -->
<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 =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
So I'm trying to run on console (from localhost, I tried also on live)
dataLayer.push({'event':'test'});
then when I look ad the Analytics event panel (real time) nothing appears on the graph. Any suggestion or idea why that's happening?
By default, Google Tag Manager doesn't send any data anywhere. When you do a dataLayer.push
call, data is simply added to the dataLayer
which sits in the client's browser.
For GTM to send data, you need to configure triggers and tags. If you want to setup GTM as passthrough so it sends whatever data you push to it to Google Analytics, here is an example: https://www.simoahava.com/analytics/create-a-generic-event-tag/
Some general info about GTM:
Variables
: they allow you to fetch data from the dataLayerTriggers
: they are rules that define when certain tags should be firedTags
: they are pieces of code that can do whatever you want (add a banner to your website, send data to Google Analytics etc...).