Should I move my GTM code into the <head>?

  • New GTM Snippet

Should I move my GTM code into the <head>?

In case you were not yet aware, Google has officially changed its recommendation on placement of the Google Tag Manager container snippet.

Previously, GTM required a single snippet of code to be placed immediately after the opening <body> tag. This code has now been split into two snippets: One to be placed in the <head> and a second to be placed in the <body> as before.GTM New Code Snippet

If you already have GTM running on your website, you might be wondering:

  • Do I need to move my GTM code to follow the new instructions?
  • Are there risks to maintaining the previous approach?
  • Why did the recommendation change?

Let’s answer these questions and help put your mind at ease.

Do I need to move my GTM code into the <head>?

The short answer is no.

There is no immediate need to move your GTM code just because the instructions have been updated. Your existing implementation will continue to work exactly the same way.

However, moving the container snippet into the <head> means that GTM will start loading earlier on the page. This gives your tags a greater chance of firing in the case that the user leaves the page or closes their browser, which can improve your data quality and accuracy.

In our tests, firing the base Google Analytics tag in the <head> (instead of the <body>) can result in a 3-5% increase in recorded sessions. Most of that traffic (95%) consisted of bounces. And for the traffic that didn’t bounce, we were able to capture a more accurate source of traffic (since the GA code was able to fire and capture the traffic source before the user navigated to the next page).

Are there risks to maintaining the previous recommendation (top of the <body>)?

It’s possible that some newer tag types which GTM now supports (e.g. Google Optimize) will not function properly using the previous placement.

If you are interested in using Google Optimize to conduct A/B testing on your site, you will definitely want to update your GTM code to the recommended placement. Otherwise, the user will likely see the page “blink” as Optimize serves up a different variant of the page.

Why did the recommendation change?

In addition to supporting Optimize and other new tag types, another potential reason for moving the container snippet into the <head> is to enable the future possibility of deploying synchronous tags via GTM. However, this is just speculation, as there is no official word on this from Google.

You should plan for moving the code when it is feasible to do so, but you do not need to do it right away and scramble your financial and technical resources.
Do you have any questions about new GTM snippet instructions? Please let us know in the comments below.

By |2019-05-17T11:57:14-04:00October 6th, 2016|2 Comments
Categories: Google Tag Manager


  1. Jeff T 2016-10-18 at 21:13 - Reply

    So I’m assuming this means any additional data layer code would go above the GTM code in the correct??

    • Max Bondarenko 2016-10-19 at 07:08 - Reply

      Hello Jeff,

      That is correct. You want to have your data layer information available before GTM even starts to load.

Leave A Comment