In short
Google Tag Manager (GTM) is a tag manager: a single code snippet installed on the site, then every tag (Google Analytics, Google Ads, advertising pixels, analytics tools) added, tested and published from an interface, without redeploying the site. It is not mandatory: it becomes useful as soon as several tags or conversion events have to be managed without a developer. Once this is done, the container is installed once and versioned, and each tag fires only with the required consent.
Why it matters
Without a tag manager, each measurement tool adds its code to the site template. After a few years, the <head> piles up scripts whose purpose nobody remembers, some duplicated, others sending data without consent. Every change requires a developer and a deployment.
GTM centralizes these tags. It offers three things that hard-coded tags do not:
- Preview: you test a tag on the real site, for yourself only, before publishing it.
- Versions: each publication creates a named version, and you can go back to the previous one in one click.
- Consent: Google tags include built-in consent checks, and you can require additional consent for any other tag.
The downside: GTM gives anyone with publish permission the power to inject JavaScript into every page. Poorly governed, it becomes a dumping ground for third-party scripts that slow the site down. See limit third-party scripts (opens in a new tab).
What it improves
- Marketing autonomy New events, pixels and conversions without a development cycle.
- Measurement reliability Testing before publishing, version history, immediate rollback.
- Compliance A single point to connect consent to every tag.
- Conversion tracking Phone and email clicks, forms, downloads, configured with triggers. See track phone and email clicks (opens in a new tab).
- Performance Neutral to negative. GTM adds its own script; the gain only comes from the cleanup it makes possible.
- Rankings No effect.
How to check
- Do you need GTM? Answer the questions in the “Decide” section. If the answer is no, a hard-coded GA4 or Matomo tag is enough.
- Is it installed? Page source: search for
GTM-. The first snippet must be at the top of the<head>, the second (<noscript>) right after<body>. - Only once? The same
GTM-ID must appear only once per page, and no GA4 tag must be hard-coded alongside it. - Does it work? In Tag Assistant, connect the site: the container must appear, with the tags fired on each page.
- Is it governed? In GTM,
Versions: each version has a name and a description, and the user list contains only current people.
How to implement
Decide
| Situation | Is GTM useful? |
|---|---|
| A single analytics tool, no custom conversions | No: a hard-coded GA4 or Matomo tag, or a CMS plugin |
| GA4 plus Google Ads, or several advertising pixels | Yes |
| Conversions to track (forms, clicks, downloads) with no developer available | Yes |
| Shopify ecommerce site | Rarely: the Google & YouTube channel and custom pixels cover most needs |
| A team with nobody able to test a tag | No: the risk of error outweighs the gain |
Step 1 — Create the account and the container
- In Google Tag Manager,
Accountstab,Create Account. - Account name (the company) and country.
- Container name: the main URL, for example
www.example.com. Target platform:Web. Create, then accept the terms.- In
Admin > User Management, add at least a second internal administrator. Reserve publish permission for people who know how to test.
Step 2 — Install the container
GTM displays the two snippets on creation, or later when you click the GTM-… ID in the workspace. The first goes as high as possible in <head>:
<!-- 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 -->
The second goes right after the opening <body> tag:
<!-- 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) -->
If a consent banner must set the default state, its code or tag comes before everything else. See handle applicable consent requirements (opens in a new tab).
WordPress
Versions WordPress 6.4 and later; Site Kit by Google and GTM4WP, November 2026 versions.
- Site Kit by Google:
Site Kit > Settings > Connect More Services > Tag Manager. The plugin inserts the container. If GA4 goes through GTM, then remove any GA4 tag added by Site Kit itself, to avoid double counting. - GTM4WP (GTM for WordPress): paste the
GTM-…ID into its settings. The plugin also fills the data layer (dataLayer) with useful information: page type, category, WooCommerce data. - Without a plugin: child theme,
header.phpfile, right after<head>and afterwp_body_open(). An update of the parent theme does not erase a child theme.
Shopify
Versions Shopify admin, all plans, November 2026.
Shopify's checkout does not accept code in templates: the intended route is the custom pixel.
Settings > Customer events > Add custom pixel.- Paste the content of the first GTM snippet, without the
<script>tags. - Subscribe the pixel to Shopify events (
analytics.subscribe('checkout_completed', …)) and push their data intowindow.dataLayer. - In GTM, create “Custom Event” triggers with these event names.
Shopify specifies that the pixel runs in a sandbox: Tag Assistant does not work with these pixels (use the Shopify Pixel Helper extension), outbound clicks are not detected automatically, and custom pixels are not covered by Shopify Support.
Wix
Versions Wix dashboard, Premium plans with a connected domain, November 2026.
Marketing & SEO > Marketing Integrations > Google Tag Manager, then “Connect” and paste the GTM-… ID.
Squarespace
Versions Squarespace 7.1, November 2026.
Paste the first snippet into the Header area of Code Injection, if your plan gives access to it. Squarespace does not let you place the <noscript> snippet right after <body>; it is optional for most uses.
Webflow
Versions Webflow, all site plans, November 2026.
Site settings > Custom code: first snippet in Head code, second in Footer code since there is no slot right after <body>. Publish the site.
Drupal
Versions Drupal 10 and 11.
The Google Tag module handles GTM containers: add the GTM-… ID in its configuration, with insertion conditions (exclude administration pages).
Laravel
Versions Laravel 11 to 13.
{{-- resources/views/layouts/app.blade.php --}}
<head>
@production
@if(config('services.google_tag_manager.id'))
<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',@json(config('services.google_tag_manager.id')));</script>
@endif
@endproduction
{{-- rest of the head --}}
</head>
<body>
@production
@if(config('services.google_tag_manager.id'))
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ config('services.google_tag_manager.id') }}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
@endif
@endproduction
With 'google_tag_manager' => ['id' => env('GOOGLE_TAG_MANAGER_ID')] in config/services.php.
Next.js
Versions Next.js 15 and 16 (App Router).
// app/layout.tsx
import { GoogleTagManager } from '@next/third-parties/google';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="fr">
<GoogleTagManager gtmId="GTM-XXXXXXX" />
<body>{children}</body>
</html>
);
}
The component loads GTM after hydration. The sendGTMEvent function from the same package pushes events into the data layer. The @next/third-parties package is marked as experimental in its documentation.
Step 3 — Add the Google tag (GA4)
Workspace > Tags > New.Tag Configuration: type Google Tag. “Tag ID” field: yourG-XXXXXXXXXX.Triggering: Initialization - All Pages.- Give the tag an explicit name (“GA4 – Google tag”) and
Save.
Events (form submitted, click on a phone number) are then added as “Google Analytics: GA4 Event” tags with their own triggers. A simple naming convention (Tool – Type – Detail) prevents a mess once you reach fifty tags.
Step 4 — Connect consent
Admin > Container Settings, tick “Enable consent overview”. Put the consent banner tag on the Consent Initialization - All Pages trigger, which fires before all others. For each non-Google tag, require additional consent in Advanced Settings > Consent Settings.
Step 5 — Test and publish
Preview: Tag Assistant opens in a new tab. Enter the site URL and browse: each page lists the tags fired and not fired.- Check in GA4,
Admin > DebugView, that the events arrive. Submit > Publish and Create Version, with a name (“2026-11-25 – Add GA4 tag”) and a description of what changes.- If there is a problem, open
Versions, choose the previous version and publish it again.
Warning: every user with publish permission can run code on every page of the site. Restrict this permission, turn on approvals if your account allows it, and review the user list whenever someone leaves.
Common mistakes
- Double installation: GA4 hard-coded or added by a plugin, and at the same time through GTM. Page views counted twice.
<noscript>snippet placed in<head>: invalid HTML, no effect.- Publishing without previewing: a tag that fires on every page instead of one skews conversions for weeks.
- Unnamed versions: impossible to tell which one broke the measurement.
- Advertising pixels firing before consent because no additional consent was required.
- Catch-all container: tags from finished campaigns never deleted, heavy A/B testing or heatmap scripts loaded permanently.
- Container in an agency's name: the company loses the history and access when it changes contractors.
Frequently asked questions
Is Google Tag Manager required to use GA4?
No. GA4 is installed with a simple Google tag in the site's code or with a CMS plugin. Google Tag Manager becomes useful when you manage several tags, for example GA4, Google Ads and an advertising pixel, or when marketing needs to add conversion events without going through a developer. For a brochure site with a single tool, a hard-coded tag is enough.
Does Google Tag Manager slow down the site?
Google Tag Manager loads its own script asynchronously, which costs little in itself. The slowdown comes from the tags it fires: advertising pixels, heatmaps, A/B testing or chat tools. A well-maintained container, with no obsolete tags and with triggers limited to the pages that need them, has a small impact. Measure before and after each addition with PageSpeed Insights.
Can I install Google Tag Manager on Shopify?
Yes, through a custom pixel in Settings, Customer events. The pixel runs in a sandbox: you must subscribe to Shopify events and pass them on to Google Tag Manager's data layer. Tag Assistant does not work with these pixels. For GA4 alone, the Google & YouTube sales channel is simpler and already tracks the main ecommerce events.
How do I undo a change published in Google Tag Manager?
Open the container's Versions tab, select the previous version, the one that worked, then publish it again. The site immediately returns to its earlier state. This is why each publication must have a dated name and a precise description: without them, finding the last healthy version turns into a guessing game when measurement breaks.
Resources
- Tag Manager Help: Set up and install Tag Managersupport.google.com
- Tag Manager Help: Install a web containersupport.google.com
- Tag Manager Help: Add the Google tagsupport.google.com
- Tag Manager Help: Preview and publish your tagssupport.google.com
- Tag Manager Help: Consent settingssupport.google.com
- Shopify: Integrate Google Tag Manager with a custom pixelhelp.shopify.com
- Next.js: Third-party librariesnextjs.org
Updated on
Topic checklist (PDF)