ulfklose wrote:My SEO buddy asked me to install Google Tag Manager on my website. To do this I have to add a snippet to the head (no problem) and to the body.
Although I haven't used "tag manager" myself yet, the script used for this is same uses as for Google Analytics. When you add your tracking ID to Settings > Accounts, X3 will load the gtag.js script from googletagmanager, at the very top of the <head>:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-1"></script><script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-59731830-1');
</script>
The only reason Google wants to load this as high up as possible in the document, is so that it can detect bounces (visitors leaving, or navigating away from the page before it's fully loaded), and perhaps to do some load-timing functions.
Is there any logic to this? As noted, the only reason for this, is so that the script might trigger a few ms earlier. There is no way to add anything top top of body in X3 ... You could inject via javascript, but that would abandon the purpose in the first place. I would be surprised if there is any practical to this.