After you create a new Google Tag Manager container, the interface asks to place two codes on your website, one in the <head> and the after right after the opening <body> tag. But have you ever wondered why are there two codes instead of one?
Usually tracking tools, like Google Analytics, Mixpanel, or others require to place one code on all pages, so how come GTM is different?
In this blog post, I’ll explain what Google Tag Manager Noscript is and why you might need it (or not, after all).
This view looks familiar, doesn’t it?
The top one ( a.k.a. the <script> part) is the essence of the Google Tag Manager. The higher you place it in the code, the sooner it will load, therefore your marketing and tracking tags will capture the data sooner. As a result, your data will be more accurate.
This code responsible for all the tracking magic that’s happening on a website, creates the Data Layer, initiates triggers to fire, dispatches tags, etc.
The <script> part a heavy lifter which does A LOT. Without it, your GTM implementation would be simply worthless.
Now, there is a totally different story behind the 2nd code, <noscript>. What if I told you it’s unnecessary? After looking at countless numbers of Google Tag Manager containers, I can say that 95% of regular everyday marketers (#madeUpStatistics) just don’t need it (maybe even more). But they still use it (because Google’s instructions say so).
Spoiler alert: a lot of things will not work at all. And I’m not talking only about fancy animations. I’m talking about actual functionality, like cookies, etc. There are some serious limitations on the web without JS, therefore not many should be choosing this option.
How Google TAg Manager Noscript works?
When JS is off and the page is loaded, the <noscript> initiates an iFrame. An iFrame is an inline frame used inside a webpage to load another HTML document inside it (for example, a webpage within a webpage).
They are used for lots of things, like web analytics, ad targeting, and embedded 3rd party content. Adsense banners? iFrame. Embedded generation form? Probably iFrame. There are many things online that utilize iFrames.
However, there’s one BUT. Only one tag type is supported when JS is off, a Custom Image Tag. I’ve written an extensive guide about it but here’s a quick recap.
CUSTOM IMAGE TAG IN A NUTSHELL
The custom image tag requests an image from a particular URL. The interesting part is that by making the request you’re actually transmitting information to a server.
For example, if you request an image via URL https://www.example.com/something?parameter1=good¶meter2=123, the receiving server processes parameter1 and parameter2 and acts accordingly (e.g. registers those parameters as an event).
In other words, when the page loads, a Custom Image tag fires which contains particular parameters (for example, Page URL). Those parameters are your data points which are transferred to the receiving server, like Google Analytics.
However, not everything is that simple. There are many limitations.
Forget all triggers, like Form Submission, Youtube Tracking, Scroll, Tracking, etc. Only Pageview triggers (Pageview, DOM Ready and Window Loaded) work when JS is off and there’s nothing we can do about it.
|Built-in Variables||Works without JS?||Comment|
|Event||Partially||Returns values of pageview-related events only|
|New History Fragment||No|
|New History State||No|
|Old History Fragment||No|
|Old History State||No|
|Scroll Depth Threshold||No|
|Scroll Depth Units||No|
|Video Current Time||No|
|1st Party Cookie||No|
|Data Layer Variable||Partially||They need to be added as query parameters. Read more.|
|Custom Event||Partially||Returns values of pageview-related events only|
|Google Analytics Settings||No|
|Lookup Table||Partially||Works only with those variables which do not depend on JS|
|Container Version Number||Yes|
So, when Exactly do I need to Use Google Tag Manager noscript?
You need to place <noscript> code on a website, if:
- Or you wish to verify the ownership of the website in the Google Search Console by choosing “Verify with Google Tag Manager” option.
- Or you don’t plan do to the aforementioned activities right now, but maybe it will become a priority in the future.
In all other cases (as far as I know), Google Tag Manager noscript is unnecessary so feel free to ignore it. If you think that I’m wrong, I’ll be more than happy to hear your opinion and learn something new.
This is not my first blog post related to Google Tag Manager noscript, so if you want to learn more how to use it, here are a couple of guides:
GOOGLE TAG MANAGER NOSCRIPT: FAQ + conclusion
This section is for those who are in a hurry and want to learn everything quicker. I’ve put a list of most common questions related to Google Tag Manager noscript with a hope that you’ll find the needed answer. This also works as a conclusion of this post:
#1. Is <noscript> part of GTM snippet required to be placed on a page. No, it’s not. Feel free to leave it out if you’re not interested in:
- website verification in Google Search Console via Google Tag Manager.
#2. Should I place <noscript> only in the <body> part of the website? Yes. <noscript> should be either placed in the <body> or not be placed on a website at all. Since <noscript> initiates an iFrame and iFrame is not supported in the <head>, your website’s code will become invalid.
#5. So no Data Layer variables in the Custom Image Tag? If you just simply pasted the <noscript> part to the website, Data Layer variables will not work. However, if you know how to code or have access to a developer, you can ask him/her to decorate the iframe link inside the <noscript> with query parameters. GTM will then fetch those query parameters if your container contains data layer variables. Read more about it there.
#8. Which triggers work when JS is disabled and <noscript> is active? Only Pageview-based triggers like Page view, DOM Ready and Window Loaded. All other triggers CANNOT properly function.
The post What is Google Tag Manager Noscript? appeared first on Analytics Mania.