Google Tag Manager official recommendation states that in order to install it you need to place the <script> code somewhere in the website’s <head> and the <noscript> part should be added immediately after the opening <body> tag.
But what should you do if a performance-obsessed developer does not agree to follow these instructions? What if a developer insists on adding GTM at the end of the <body>? Or maybe your content management system does not allow you to place the code in the <head>?
The result of this kind of situations is that both Google Tag Manager codes are added somewhere in the <body>, most likely even somewhere in the footer. If that’s the case, you’re probably wondering what will be the consequences to your tracking implementation if Google Tag Manager is in the body.
In general, it will work fine. The only thing that is affected is the time when it will load. The higher the GTM container snippet is placed in the page source code, the sooner it will load, and obviously, the sooner your tags will start firing and tracking visitor’s interactions.
So if the circumstances do not allow you to follow Google’s recommendations, don’t panic. You’ll still be able to use GTM. Even if it is somewhere in the body.
The only combination that will make your website’s code invalid is if someone added the 2nd GTM code (<noscript>) to the <head>. All other options are ok. I’ve explained them in greater detail here.
Just keep in mind that in such a case, there will be a higher chance that GA and other tracking tools within GTM will not catch some visitors at all. If your website loads pretty slowly and the visitor abandons the site before the GTM container in the footer managed to load (this must happen quite rapidly), your analytics/marketing tools will miss it (because GTM was not loaded at that moment and Google Analytics (or other tags) were not fired yet.
Unfortunately, I cannot give you numbers of how many visitors can you possibly miss in your analytics reports under these circumstances. There are too many variables and conditions that affect this. IT DEPENDS.
Google Tag Manager in Head or Body: Summary.
Even if you add both GTM codes to the <body> of the website, GTM will still work fine.
However, it is better if you add the <script> code to the head. It means that GTM will start loading faster and your website measurement setup will be more accurate. The same applies if you want to install Google Analytics via GTAG.
But, on the other hand, having GTM load as soon as possible can affect the page loading speed. But there are other options for how to mitigate this.
The post Google Tag Manager Container Code. In <head> or <body>? appeared first on Analytics Mania.
Read MoreAnalytics Mania