Google Tag Manager NoScript Code – Do You Need It?

Google Tag Manager (GTM) requires users to use two snippets of code, the first(script) in the header and the second(NoScript) in the body section of the page. This can be problematic especially for platforms like WordPress. So if like me you like using WordPress and don’t want to keep adding plugins that negatively impact page load speeds, then here is a post could help you solve both problems. Julius Fed (Fedorovicius) head of Developer Operations at Omnisend wrote an inciteful post on exactly this and I wanted to share some of that, so here goes.

WHAT IS GOOGLE TAG MANAGER NOSCRIPT?

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).

 

TWO CODES

This view looks familiar, doesn’t it?

Google-tag-manager-installation-guide

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).

Why?

 

GOOGLE TAG MANAGER NOSCRIPT WORKS ONLY IN BROWSERS WHEN JAVASCRIPT IS OFF

Unfortunately, I haven’t found any relevant statistics regarding how many people browse the web without JavaScript, but I don’t think that there are many of them (even though I’ve seen others saying different things). Just try to disable JavaScript for a while and browse your favorite websites. Take a closer look at what happens.

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.

Anyway, now it probably makes sense to you, why that 2nd code is surrounded by <noscript>. Because it functions only when JavaScript is disabled.

 

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.

Anyway, back to the <noscript>. When the page loads, an iFrame loads as well, and tags are fired through it. That’s like a workaround for the non-JavaScript environment. If JavaScript is enabled, the contents of the <noscript> tag are ignored and all tags are fired normally based on their standard rules.

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.

 

SO, WHEN EXACTLY DO I NEED TO USE GOOGLE TAG MANAGER NoScript Code?

You need to place the <noscript> code on a website, if:

  • You plan to track visitors who have disabled JavaScript on their browser.
  • 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. To see Fed’s  GOOGLE TAG MANAGER NOSCRIPT: FAQ + CONCLUSION go here

With all the GDPR work I have been doing Google Tag Manager has been a great tool and now that I understand the need (or lack of it) I will certainly be making some changes to my implementation of GTM. Hopefully, this will help you. Will you stop using the NoScript code in the future? Let me know what you think in the comments below. 

John

About John

No Comments

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.