4/11/2026
This guide is for the marketing manager, SEO or analyst who needs to install Google Tag Manager on a site and get usable measurement from the very first release. It covers the account and container, the official two-part snippet, placement by CMS, the exact role of the noscript and Google Search Console verification through GTM.
For the concepts of tags, triggers and variables, start with our guide to Google Tag Manager. Here, you decide where the code goes, what to check and what to document.
A Reliable, Repeatable Method: Goals and Prerequisites
An installation is judged by the quality of the data it produces and by how well it survives redesigns.
The Goal: Install, Test and Protect Data Collection From Day One
A solid implementation aims for four outcomes:
- load the container on every relevant page, at minimum the whole public site;
- protect performance, because
gtm.jsloads asynchronously but stacking scripts still harms user experience; - avoid double-counting, for example measurement already present in the theme and then added again via GTM;
- make the setup testable using Preview mode and Tag Assistant.
Before You Start: Access, Environment, Caching and Publishing Rights
Before making any changes, secure these five points:
- Access to the code: FTP, repository, theme or CMS interface, with the ability to edit the
<head>and the opening<body>tag. - GTM publishing rights: the "Publish" permission, or a process where an authorised person publishes on your behalf.
- Environment: if you have a staging environment, install there first, then in production.
- Cache and CDN: plan to purge CMS, server and CDN caches; otherwise you will be testing an outdated version.
- Existing duplicates: identify scripts already injected by the theme, a module or a native integration, a check included in any technical SEO audit.
Create Your Account and Container: Retrieve the Container ID for Deployment
Sign in at tagmanager.google.com, then create an account and a container. GTM is organised in four levels: the account, the container, the workspace and the published version.
Set Up a "Web" Container: Naming Conventions and Tag Governance
When creating it, three fields matter:
- the account name, typically your organisation's name;
- the primary country;
- a container for the Web platform (website or blog).
Name the container using the domain and environment, for example example.com - prod and example.com - staging if you separate your environments. This convention reduces publishing mistakes and makes later checks easier.
Where to Find the GTM-XXXXXXX Identifier: What It Does and What to Check
The container ID, in the format GTM-XXXXXXX, is the key that loads the correct container on your site. It appears at the top of the workspace, and in the installation script URL (…/gtm.js?id=GTM-XXXXXXX).
Check that you are installing the ID for the right environment, production or staging. Using the wrong ID is a classic pitfall: everything appears to be in place, but you are debugging a different container.
Understanding the Two Snippets: GTM Script and GTM Noscript
GTM provides two complementary snippets with distinct roles, placed in two specific locations on the page.
Where to Place the Code in <head> and <body>
The first snippet goes in the <head>, as high as possible; the second goes immediately after the opening <body> tag. Here is the official snippet, to be copied without modification, replacing GTM-XXXXXXX with your ID:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
The first seven lines go in the <head>, the last four immediately after <body>.
The GTM Script in the <head>: Exact Placement and Common Mistakes
Place the script just after your <meta> and <link> tags, and before any other scripts: GTM is then among the first scripts to execute, which reduces the risk of missing events early in the page load. The script does three things:
- initialises
window.dataLayerif needed; - pushes the
gtm.startstart event; - loads
gtm.jsasasyncwith the container ID.
Implementation mistakes look alike from one site to the next; the following table links each one to its consequence and its fix.
| Mistake | Consequence | Fix |
|---|---|---|
| Script placed too low | Missed navigation signals | Move it to the top of the <head> |
| Edited snippet | Unpredictable behaviour, risky maintenance | Copy the official code |
Snippets swapped or iframe in the <head> | Invalid HTML | Script in <head>, noscript in <body> |
| Two containers without a strategy | Double-counting, difficult diagnosis | One container per documented scope |
| Old hard-coded tag left in place | Double tagging | One implementation source per tag |
The Noscript Tag: What It Does and Does Not Do
In HTML, <noscript> provides fallback content when scripts do not run; when JavaScript is enabled, the browser ignores it. The GTM block then loads an iframe pointing to ns.html, a remote resource called without JavaScript. An iframe is not valid in the <head>: this is why the block goes immediately after the opening <body> tag, and not lower down.
This fallback does not replicate GTM. Without JavaScript, only the "Custom Image" tag can fire, on page load triggers, with no data layer and no CMP. The following table summarises what happens in each visit context.
| Context | What loads | What is measured |
|---|---|---|
| JavaScript enabled | gtm.js; the noscript is ignored | All tags, subject to consent |
| JavaScript blocked | The ns.html iframe | "Custom Image" tags on page load |
| Bot without JavaScript | The iframe, if the agent interprets the noscript | Minimal signal, which pollutes data if not filtered |
The decision hinges on consent: without JavaScript, no CMP collects the visitor's choice. In France, no non-exempt tag should therefore fire in this context; if you configure a "Custom Image" tag for the fallback, reserve it for exempt measurement and pass no personal data through it.
Keeping or Omitting the Noscript: Weighing Your Constraints
The noscript is technically optional but recommended: it avoids a total absence of signal in environments without JavaScript (hardened browsers, IT policies, automated tools). If your CMS prevents you from writing immediately after the opening <body> tag, you have three options:
- accept the missing fallback: GTM works normally as long as JavaScript is enabled;
- insert the block lower in the body: less effective, but still valid;
- update the templates: theme, layout or root file, to regain control over the opening body tag.
CMS-Specific Installation: WordPress, PrestaShop and More Advanced Setups
The reference approach remains inserting both snippets into the source code. Depending on your CMS, files, modules and caching constraints vary; the following table shows where to paste the code and which pitfall to watch.
| CMS | Where to paste the code | Pitfall |
|---|---|---|
| WordPress (manual) | The theme's header.php | Code overwritten by a theme update |
| WordPress (plugin) | Field that takes the GTM-XXXXXXX ID | Competing injection from the theme or another plugin |
| PrestaShop | head.tpl, code wrapped in {literal} | Template recompilation to restore after validation |
| Shopify | Theme for non-checkout pages | Checkout: custom pixels, GTM not accepted |
| Next.js | Root layout, once only | Double injection by a component and the platform |
WordPress: Add the Code Without Duplicating Tags or Breaking the Theme
For manual insertion, locate via FTP or the theme editor the file containing the <head> and the opening <body> tag, then add both snippets in their places. With a plugin, document where GTM is injected and disable any competing injection from the theme or another module.
PrestaShop: Clean Templates and Deployments That Survive Updates
Without a module, implementation goes through the theme templates, typically themes/your_theme/templates/_partials/head.tpl. The Smarty engine interprets curly braces: wrap the code in {literal} to prevent it from being altered.
During the change, set template recompilation to "recompile if files have changed", then return to optimal settings after validation so as not to degrade performance. A module that only asks for the container ID remains an option, with the same vigilance about duplicates as on WordPress.
Advanced Cases: SPAs, Multi-Domain, Staging and Environments
Installing both snippets on every page still holds, but the architecture complicates validation in three cases:
- SPAs: URL changes do not reload the page, so measurement must rely on events pushed to the data layer;
- multi-domain and subdomains: choose one or several containers and document what lives in GTM and what lives in the code;
- staging: test on this environment first, checking that the installed ID is correct and that your triggers do not contaminate production.
Installation Verification: Confirm Loading Before Publishing
An installation is only complete once the container loads and the expected tags fire once only across a realistic journey. Launch Preview mode from the workspace: Tag Assistant opens your site and shows, event by event, what fires; the old Tag Assistant Legacy extension is discontinued and does not read GA4. The full procedure, from the network tab to DebugView, is in our guide to testing Google Tag Manager.
Final Checklist: Single Tags, Full Coverage, Clean Publishing and No Duplicates
Before considering the installation finished, tick every point:
- both snippets are present, once only, on every template, including error pages;
- the correct container ID is installed, with production and staging kept distinct;
- the container loads on key pages: homepage, SEO landing pages, forms, transactional pages;
- Preview mode connects and displays events;
- no critical tag is duplicated, whether analytics or key events;
- publishing goes through a named, described and dated version.
Data Quality: Data Layer, Consent and Measurement Reliability
Data stability then depends on two pillars. The first is a clean data layer: business information pushed to the dataLayer fires tags from a stable signal rather than a fragile DOM element, which, for example, distinguishes a click on a button from an actual form submission.
The second is consent, which prevents certain tags from firing and creates discrepancies between tools. Keep behaviour explainable and documented, then test it:
- under "consent accepted" conditions;
- under "consent refused" conditions, where the result differs;
- with a note describing the tags concerned and the expected effect on the figures.
The data contract and the consent setup each have their own guide, listed in the "Depending on your situation" block below.
Connecting the Tools: Analytics and Search Console
The value of the installation comes from linking visibility in search engines with behaviour on the site.
Verify Search Console With the GTM Container
Google Search Console accepts property verification through Google Tag Manager. Three conditions must be met:
- the property is a URL prefix property;
- the container snippet is in place, with the script in the
<head>; - the verifying account has the "Publish" permission on the container.
Choose a stable method, one that depends on no particular environment, cache or partial template, and document it. The other methods and their use cases are detailed in our article on Google Search Console validation.
Once both sources are reliable, combining Search Console and GA4 via API links queries, entry pages and outcomes, and surfaces measurement anomalies or journey breakpoints.
After Installation: Governance, Versioning and Tag QA
Once GTM is in place, stability comes from process:
- version every publish with a name, description and context;
- test in Preview mode before every publish;
- limit publish permissions to accountable roles;
- remove unused tags to protect performance.
Depending on Your Situation
With installation complete, the next step depends on what you need to measure:
- You need to track forms or purchases: define the events and their parameters with our guide to the data layer in GTM.
- Your site displays a consent banner: set up the CMP, state and firing chain once with our article on cookies and consent in GTM.
- You need to add third-party scripts: choose the right tag type and secure custom HTML with our article on GTM scripts and tags.
- You want to read visibility and behaviour together: bring the two tools together with our guide to Search Console and Google Analytics.
Once collection is reliable, the next step is to check the technical health of the pages you measure: the Incremys 360 GEO and SEO audit is the starting point for prioritising those fixes.
FAQ: Installing Google Tag Manager
Where should the GTM code go?
The GTM script goes in the <head>, as high as possible, after the <meta> and <link> tags and before other scripts. The noscript block goes immediately after the opening <body> tag. Both snippets must appear once only on every page template.
Is the noscript needed?
The noscript is optional but recommended, because it avoids a total absence of signal when JavaScript is blocked. When JavaScript is enabled, the browser ignores it and nothing changes. If your CMS prevents you from writing it right after the body tag, you can omit it or place it lower, documenting that choice.
Does the noscript set cookies without consent?
The noscript sets nothing by itself: only "Custom Image" tags configured for this fallback can fire. Without JavaScript, no CMP collects the visitor's choice. In France, no non-exempt tag should therefore fire in this context, and no personal data should pass through it.
Can GTM be installed without a developer?
Yes, a WordPress plugin or a PrestaShop module lets you install GTM by simply pasting the container ID into a field. You still need admin access to the CMS and the "Publish" permission in GTM. The main risk remains duplication with an injection already present in the theme.
How can I check that GTM is installed correctly?
GTM Preview mode, opened in Tag Assistant, confirms that the container loads on the page being tested. Then check that the expected tags fire once only. As an additional check, inspect the page source: the script should be in the <head> and the noscript immediately after <body>.
How do I prevent double tagging after a redesign or the installation of a new plugin?
One implementation source per tag prevents double tagging. Before and after the redesign, list the injections from the theme, modules, native integrations and hard-coded scripts. Then run a complete journey in Preview mode and confirm that every critical event appears once only.
How do I verify Search Console with GTM?
Search Console can be verified through GTM for a URL prefix property. The container snippet must be in place on the site, and the verifying account must have the "Publish" permission on the container. Choose a method that depends on no particular cache or environment.
.png)
.jpeg)

.jpeg)
%2520-%2520blue.jpeg)
.avif)