
July 17, 2025
How to Install Google Tag Manager on your Website
Updated: July 17th, 2025
Even though this topic might sound way too basic for some of you, remember that there are nuances you should keep in mind. In this blog post, I’ll describe several ways to install Google Tag Manager on a website, highlighting the pros and cons of each option.
If you haven’t done this, first, you should create a Google Tag Manager account and a container.
Table of Contents
Here’s what you will learn in this article
- Create a Google Tag Manager account
- Where can I find the Google Tag Manager code?
- Add Google Tag Manager container code to the website
- Check if GTM plugins are available
- Why should I place GTM code in website’s head?
- Check if GTM is working
- Data Layer
- Common mistakes
- Frequently asked questions
- Finals words
Create a Google Tag Manager Account
To get started, first, let’s create a GTM account. Go to Google Tag Manager official website and click the main call-to-action in order to create a new Google Tag Manager account.
Just like with any other Google product, you will use the same Google account for Tag Manager. So, if you’re already on Gmail (Google Ads, Google Analytics, etc.), you will be automatically logged in to Google Tag Manager. If not, create a Google account first (I will not show that procedure, so you’re on your own here ).
Once you log in, you’ll be asked to create a new Google Tag Manager account and a new container.
A Google Tag Manager account works the same as a Google Analytics account. Usually, it’s for a company/business/client, while a container is usually for a website or application. A single container can contain many tags, triggers, and variables.
However, if there are several websites that belong to a single business and their structure is very similar (plus, their tracking implementation is similar), feel free to use one container on multiple websites. I have written more about this topic here.
Where can I find the Google Tag Manager code?
Google Tag Manager provides the exact code and instructions on where to add it to your website. There are two places where you can find it:
- By clicking the container ID (located next to Publish and Preview buttons)
- Or by going to Admin > Account > Container > Install Google Tag Manager
Any of these options will open instructions on how to install the Google Tag Manager code on your website + the code snippets that you must add to a site.
Add Google Tag Manager container code to the website
Follow the instructions and place the first code (which is surrounded by <script> tags) somewhere between <head> tags of your website. This code is the key part. It tells your page to load your Google Tag Manager container asynchronously, which means that the rest of the page can continue loading while Google is doing its magic.
This “asynchronous” loading means that the GTM container loads independently, on a separate track from the rest of your website’s content. If, for some reason, the GTM server is slow to respond, it will not prevent your text and images from appearing. This makes sure that your tracking implementation will not become a bottleneck that negatively impacts the user’s experience by slowing down your page load times. I mean, the content of GTM can still have negative impact on loading speed.
However, based on my experiments, the performance is better than adding tracking codes directly to the source code of the website.
Here’s an example of the website’s <head> where you could add the Google Tag Manager <script> code.
The second Google Tag Manager code (noscript) should be placed immediately after the opening <body> tag. This works as a backup, allowing you to track users without Javascript. The <noscript> tag tells the browser if the user does not have JavaScript enabled, then render an iframe version of the Google Tag Manager Container to the page.
Important: While you can place both these codes in <body> only, you must not add them both in <head>. As it was mentioned before, <noscript> part renders an iframe, which is not allowed in <head>, otherwise, you’re website’s HTML will be invalid.
So the possible options are:
- <script> code is added to the <head> and <noscript> to the <body>
- both <script> and <noscript> codes are added to the <body>
Another thing to mention is that the <noscript> part of the Google Tag Manager code is not required. You’ll need it only if you want to track visitors without enabled JavaScript (which is a very small fraction of the web traffic with many limitations) or if you want to verify the ownership of Search Console Property.
While including the <noscript> snippet is a recommended practice, it is helpful to understand its limitations. Because it can only function when JavaScript is disabled in a user’s browser, its tracking capabilities are minimal. It can tell you that a page was viewed, but it cannot track more complex interactions like button clicks, form submissions, or video plays. The vast majority of your data will come from the main <script> tag, so do not be too concerned if a particular website platform makes it difficult to place the <noscript> portion perfectly.

Check if GTM plugins are available
If you are using a popular Content Management System (CMS) that allows using plugins, chances are that there is already a plugin that installs Google Tag Manager for you. All you need to do is just to add your Google Tag Manager container ID.
Here are several examples of such plugins:
- For WordPress – I always recommend GTM4WP (hands-down)
- I saw that Magento also offers a bunch of Google Tag Manager plugins
- on Shopify, you’ll also find several good ones, for example, this.
That should save you some time. Also, some platforms offer built-in Google Tag Manager integration (for example, WIX).
However, if you decide to move with the manual installation (with or without a developer’s input), here’s what you need to know (continue reading)
Why should I place the Google Tag Manager code in head?
While this is not 100% required, it is highly recommended that you place <script> part of GTM code into <head> of your website.
Why? It’s better for tracking. The higher up in the page the snippet is, the faster it is loaded. In the older version of Google Tag Manager, it was recommended to place the snippet in the body tag, but this would potentially miss users who left your page before the body tag loaded (due to slow page speed).
If your website is pretty heavy, it might take more than a few seconds for Google Tag Manager to start loading in <body>, but in <head> it would be initiated much faster, thus, you could catch more visitors and see how they behave.
This could empower you to identify the percentage of traffic that bounces before the page completely loads.
Remember, the lower your tracking codes are placed in the website’s code, the later they will be launched.
Check if Google Tag Manager is working
After the GTM code is implemented on a page, you need to make sure whether it was actually properly installed. There are several options you can choose from (all of them are explained in detail here):
- Right-click on your website’s background -> choose View page source and find that code (by looking for gtm.js)
- Enable preview and debug mode and see whether it appears on the screen. Click the Preview button in the top right corner of GTM interface, then go to the website (refresh it) and check whether a Google Tag Manager preview and debug panel appeared at the bottom of the screen.
The tips above are the main ones you could try right now. I have a longer (and more detailed) list here.
Need some custom data on every page? Use the Data Layer
When Google Tag Manager code is placed on your website, it automatically creates a Data Layer.
It’s like a virtual layer of your website that contains various data points (Get it? That’s why it’s called a data layer.). With its help, Google Tag Manager is able to read, push, and transfer data between your website and other tracking tools.
If you want to push some data to dataLayer when the page loads, you need to place that data above the Google Tag Manager code. Like this:
<head> <script> window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'customerType': 'vip', 'registrationCountry': 'United States' }); </script> <script> <!-- Google Tag Manager --> ... <!-- End Google Tag Manager --> </script> </head>
If you don’t possess coding skills, this work should be done by a developer (because just blind copy-pasting will not work). There must be some logic written that adds actually dynamic information to the dataLayer (e.g. if a user logs in, his/her actual customerType should be added to the Data Layer.
Data layer is not an easy concept for beginners to grasp. So, if you are confused about this chapter, don’t worry. Everyone was. Here are some additional resources for you to read to get more familiar with it:
Common mistakes
Installing Google Tag Manager is usually a smooth process, but a few common slip-ups can lead to frustration and prevent GTM from working correctly. Here are the most common mistakes that I have seen:
#1. Messing up the quotation marks. When marketers get the GTM container code and send it to the developers, they often do it with rich text editors, like Microsoft Word or Google Docs. Such editors are known for messing up the quotation marks in the code, which breaks the code. Here’s an example of incorrect quotes:
That’s why when I send the codes, I usually do that via plain text editors or code repositories like Github or Pastebin.
#2. Not adding the container snippet to all pages. It’s not enough to install GTM just on the home page. Google Tag Manager will work only on those pages where it is installed. Thus, it must be added to all pages. Most modern websites handle this for us (when you add a code to a single place and then it gets reused on all pages) but it’s still something that’s worth checking.
Frequently Asked Questions
So, I’ve described what the perfect and recommended scenario looks like:
- <script> part of Google Tag Manager code goes to <head> (usually before the closing </head> tag).
- <noscript> part goes after the opening <body> tag.
But real-life situations are far from perfect, and sometimes we have to deal with very limited circumstances. In this chapter, we’ll discuss other not-so-perfect options and what the possible outcome might be.
#1. Can I place noscript; part somewhere else rather than right after body tag?
Yes, you can.
This usually happens while working with limited content management systems (CMS), which prohibit you from accessing the website’s source directly and only allows to paste tracking codes into a dedicated field. All content of that field is then placed at the very end of website’s HTML.
While it is not recommended, it is possible to put the Google Tag Manager <script> and <noscript> tags in the body section, as shown below. If you are planning on, or already using GTM to run A/B testing, then you definitely should place the top snippet in the head to make sure your experiments run smoothly.
But if you’re planning just to utilize some basic Google Analytics tracking (or something like it), then you should be fine.
But keep in mind, the lower your tracking codes are in the website’s code, the later your tracking tags will fire.

#2. Can I remove <noscript> part and use only <script>
Yes.
If you don’t care about people who disable JavaScript completely, you can forgo the <noscript> part completely. Remember: putting it in the HEAD will create non-compliant HTML since an iframe shouldn’t be there.
You should either put noscript part in the <body> or don’t use it at all.
#3. I Installed GTM few years ago; Both <script> and <noscript> parts are in body. Is it bad?
It’s fine.
As mentioned before, before late 2016, Google’s recommendation was to place the entire Google Tag Manager code to <body>. This is still working to this day.
But remember that you might be losing some tracking data because GTM (placed in <body>) starts loading a bit later compared to Google Tag Manager code placed in <head>.
So, if you have time and resources, I definitely recommend moving <script> part to <head>.
How To Setup & Install Google Tag Manager: Final Words
The advice here is simple: just follow Google’s instructions.
The most recommended way how to install Google Tag Manager code is to place <script> part to <head> of your website, and <noscript> part should be place somewhere in <body> (preferably right after <body> tag).
This ensures that your marketing tags in GTM will be fired as soon as possible without much of data loss.
The lower the Google Tag Manager code placement is, the later your tags will fire. As a result, you might lose a portion of your data.
If you are using a popular content management system to run your website (e.g. WordPress), look for ready-made plugins that will help install Google Tag Manager with a couple of clicks.

34 COMMENTS
Im using 3d Cart, it has a [very] limited CMS as you mentioned. I understand it's possible to install the GTM script code in the footer and abandon the noscript and compensate for the little visitors that disable JS nowadays. However, our website is old and is still in the development process of being revamped, so load times are a bit slow thus making me worry about installing GTM in the footer. Should I just go to each page and install the GTM code myself?
Hey, depends on the number of pages and whether new pages are added often.
If there are many pages and new pages are constantly added, I'd go with the footer.
Otherwise the implementation would be prone to errors.
Thank you. I've figured out that I have access to the frame.html. Would it be a problem if I added it as high in the head as possible?
Should not be a problem. But it will also work right before the closing tag.
Hi Julius,
Thanks a lot for this wonderful tutorial on Google Tag Manager
I wonder if you're familiar with Symfony and if so grateful
if you can tell if I can add the GTM code snippet to the body part as I cannot really do so in the section.
Thanks again.
Symfony is a PHP framework, meaning that you can add it anywhere you want. If you face some limitations, this means that your Content Management system is probably causing them, not Symfony itself.
To answer your questions, yes, you can add both code snippets to the body.
Hi Julius, thanks for great contributions. One of our clients have installed the first GTM snipet in the section, but I can't see it properly from within developer tools and/or "View Page Source". I can only see FB/analytics script tags being fired somewhere in the but can't really identify where exactly they have added the GTM snippet. Is it possible to see exactly on which line it was added?
the reply box truncated the gtml element I mentioned (head section), it is meant to read GTM is installed in the head section
Hey, but do you see the GTM container when you enable the GA Tag Assistant Chrome extension? Because if that plugin does not display GTM (present on a page), then it means that nobody has actually added the snippet.
When you have enabled the Preview and Debug mode, do you see the Preview mode on that page/website?
Sorry, I could have added that context in my first comment. Yes, it shows in Google tag assistant, and yes the preview and debug mode works too. I am just used to being able to check where in the code the GTM snippet has been added by checking "View Page Source" as the developer tools section does not (it shows the scripts that have fired and changed the DOM). But for this client I cannot see it anywhere. Perhaps a weird edge case, but you might have come across it?
Sometimes JavaScript code is stored in a separate website file that is loaded on a page. GTM code might be placed there. If you share a link to that page, I can take a look.
Good day, Julius, I'm a consulting social worker without any coding experience and have a basic Google My Business website.
I would like to be able to cut and paste the relevant code into every page of my website as instructed by Google Tag Manager but have absolutely no idea how to go about doing this.
Any assistance will be greatly appreciated
Kind regards
You cannot add tracking codes to Google My Business profiles
Dumb question: If you already have the Google Analytics code on your website but now want to track outbound clicks using Google Tag Manager, do you REMOVE the Google Analytics code and replace it with the Google Tag Manager code? Or do you just ADD it above the Analytics code in the section? Thanks.
It is recommended to remove the hardcoded GA code, migrate fully to Google Analytics via GTM.
But it will also work if you keep the hardcoded Google Analytics and implement the outbound link tracking via GTM+GA. Just make sure that hardcoded GA and GA+GTM are not tracking the same things/interactions (otherwise you will have duplicate data).
Hi thanks for all the useful info, but should the code be added to just the index.htm page or to every .htm page?
Depends on how the website is coded. Just make sure that in the final result, GTM code is on EVERY page. On some website's it's enough to edit one file (and all pages inherit that), on others - multiple.
Hey this is really helpful. My issue is that the tag plugin I'm using doesn't provide an option to put code in the body. It only gives me the header and footer options. So based on your advice I'm just gonna leave the noscript code out, but if you have a better solution I'd be all ears! Thanks!
Feel free to leave the noscript part out. However, if you plan to track visitors with javascript disabled but don't care about the Google Search console property verification via GTM, noscript can also work in the footer.
Hello
I have installed GTM in my wordpress website and tested with the preview button in tag manager.
Now every time if i have to check page views status how do i do it?
Do i have to go to analytic.google.com or can i check it within tagmanager.google.com
Find the google tag manager tutorial or beginners on my blog and learn how to do it.
Hi, i have a question about the last paragraph. It's a Wordpress issue. Let's say tag manager was hardcoded and tags/triggers have already been installed. What if I then needed to use the GTM plugin (by Thomas Geir) for using the datalayer etc., would that create issues or install the GTM snippet twice? How to safely make the switch? Thanks so much.
That plugin has the option to turn off GTM and just add the data layer. Use that.
Thank you so much
How to get GTM Id?
https://www.analyticsmania.com/post/google-tag-manager-id/
Hi Julius,
I asked our company developer to add GTM code to our website. She let me know she added the code and deleted the old GA code. Is that okay?
If you haven't replicated the same GA tracking in GTM, it means that you are now missing new GA data. GA code should be removed only when you completely replicate the GA tracking in GTM
I would like to know your opinion on "Do I really need to add the Tags to all the pages?" Because I have some HTML websites that contain hundreds of pages... And some of them are "privacy policy", etc. You know, those kinds of pages that you don't want to track... Not adding them would save me hours of copy paste...
What do you personally do in that case? Thanks for your help.
If there are pages where you don't want to track visitors, don't add GTM there
Hi Julius, I'm a marketer not a developer so bear with me. We're using GTM4WP mainly for the GA4 Ecommerce Tracking which is all working fine.
But I'm having problems using the DataLayer to track form submissions for Microsoft Dynamics 365 forms and SnapChat Events - and I wonder if it's because we do not have the standard GTM tag in the source code which as you've mentioned includes the DataLayer - so as we're using GTM4WP do I need to add code for the DataLayer to work?
Hi Julius,
How to place Google Tag Manager on a website so that it does not affect loading speed pagespeed.web.dev ????
There is no way. An empty GTM container does not affect the page speed significantly. What matters is what tags you put inside of it https://www.analyticsmania.com/post/google-tag-manager-impact-on-page-speed-and-how-to-improve/
Hi Julius,
After pasting the gtm code in the , I see the following message displayed under Issues in Developer tools for every webpage in Chrome:
Reading cookie in cross-site context will be blocked in future Chrome versions
Cookies with the SameSite=None; Secure and not Partitioned attributes that operate in cross-site contexts are third-party cookies. In future Chrome versions, reading third-party cookies will be blocked. This behavior protects user data from cross-site tracking.
Please refer to the article linked to learn more about preparing your site to avoid potential breakage.
1 cookie
Name Domain & Path
ar_debug .www.google-analytics.com/
Would this cause issues later?