# Set up Google Tag Manager if needed

- Check 41.05 · Tracking and analytics setup · Critical
- Source: https://checklist-seo-geo.com/en/tracking-analytics-setup/set-up-google-tag-manager-if-needed
- Decide whether Google Tag Manager is useful to you, create the container, install it on your CMS or framework, add the Google tag, test, then publish.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/tracking-analytics-setup/set-up-google-tag-manager-if-needed.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## 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](https://checklist-seo-geo.com/en/performance-core-web-vitals/limit-third-party-scripts).

## 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](https://checklist-seo-geo.com/en/tracking-analytics-setup/track-phone-email-clicks).
- **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

1. **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.
2. **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>`.
3. **Only once?** The same `GTM-` ID must appear only once per page, and no GA4 tag must be hard-coded alongside it.
4. **Does it work?** In [Tag Assistant](https://tagassistant.google.com/), connect the site: the container must appear, with the tags fired on each page.
5. **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

1. In [Google Tag Manager](https://tagmanager.google.com/), `Accounts` tab, `Create Account`.
2. Account name (the company) and country.
3. Container name: the main URL, for example `www.example.com`. Target platform: `Web`.
4. `Create`, then accept the terms.
5. 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>`:

```html
<!-- 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:

```html
<!-- 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](https://checklist-seo-geo.com/en/tracking-analytics-setup/handle-applicable-consent-requirements).

### 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.php` file, right after `<head>` and after `wp_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.

1. `Settings > Customer events > Add custom pixel`.
2. Paste the content of the first GTM snippet, without the `<script>` tags.
3. Subscribe the pixel to Shopify events (`analytics.subscribe('checkout_completed', …)`) and push their data into `window.dataLayer`.
4. 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.

```blade
{{-- 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).

```tsx
// 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)

1. `Workspace > Tags > New`.
2. `Tag Configuration`: type **Google Tag**. “Tag ID” field: your `G-XXXXXXXXXX`.
3. `Triggering`: **Initialization - All Pages**.
4. 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

1. `Preview`: Tag Assistant opens in a new tab. Enter the site URL and browse: each page lists the tags fired and not fired.
2. Check in GA4, `Admin > DebugView`, that the events arrive.
3. `Submit > Publish and Create Version`, with a name (“2026-11-25 – Add GA4 tag”) and a description of what changes.
4. 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 Manager](https://support.google.com/tagmanager/answer/6103696?hl=en)
- [Tag Manager Help: Install a web container](https://support.google.com/tagmanager/answer/14847097?hl=en)
- [Tag Manager Help: Add the Google tag](https://support.google.com/tagmanager/answer/14842872?hl=en)
- [Tag Manager Help: Preview and publish your tags](https://support.google.com/tagmanager/answer/14842769?hl=en)
- [Tag Manager Help: Consent settings](https://support.google.com/tagmanager/answer/10718549?hl=en)
- [Shopify: Integrate Google Tag Manager with a custom pixel](https://help.shopify.com/en/manual/promoting-marketing/pixels/custom-pixels/gtm-tutorial)
- [Next.js: Third-party libraries](https://nextjs.org/docs/app/guides/third-party-libraries)

Next steps: [check data collection](https://checklist-seo-geo.com/en/tracking-analytics-setup/check-data-collection) and [track conversions, forms and quote requests](https://checklist-seo-geo.com/en/tracking-analytics-setup/track-conversions-forms-quote-requests).
