Google Tag Manager Setup Guide: Container, GA4 Tag and Safe Publishing

Crawvix Editorial Team · Published November 4, 2026 · Last updated November 4, 2026 · 11 min read

A container box holds three tag blocks, with a preview magnifier above it and a publish button carrying a version label.

Every analytics or advertising tool asks you to paste a snippet into your site. After a year you have five snippets, nobody remembers who added which, and a template change quietly deletes one. Google Tag Manager (GTM) is a way to put one snippet on the site and manage the rest from a web interface, with a preview mode before changes go live and a saved version every time you publish.

This Google Tag Manager setup guide walks through the first working configuration: create an account and container, install the container code, add a Google tag for GA4, track one real event, test it in preview and publish it safely. It is for small-site owners, marketers and the developers who help them. It does not speed up a site, it does not decide what you may track, and the privacy notes are not legal advice.

Short answer: For a Google Tag Manager setup, create a Web container at tagmanager.google.com, paste its two snippets into your site, add a Google tag with your Tag ID and the Initialization - All pages trigger, test with Preview, then use Submit to publish a named version. Remove any old direct GA4 snippet.

Before you begin

You need a Google Account, permission to edit your site's templates (or a builder or CMS that supports Tag Manager), and a GA4 property with a web data stream. If you have not created one, follow the GA4 setup guide for small businesses first and keep the Measurement ID or Tag ID to hand.

Find out what is on the site now. If GA4 is already installed directly, you will remove that snippet in Step 4, or every visit is counted twice; Google's help says not to add more than one Google tag to a page. Take a copy of the page templates you will edit, and test on a staging copy where you can; the pre-launch QA guide covers keeping staging separate from the live site and its analytics IDs. Allow about an hour.

Decide who may publish. Anyone who can publish can change what runs on every page, including scripts that slow pages down or collect data. See the third-party scripts guide for the cost side.

How does Tag Manager work?

A container is the box of settings for one site. Inside it, tags, triggers and variables do the work, you edit in a workspace, and each publish saves a version.

Piece What it does Example
Tag The thing that runs, such as sending data to GA4 A Google tag
Trigger The condition that makes a tag run Initialization - All pages; a click on a phone link
Variable A value a tag or trigger can read Click URL
Workspace Your unpublished draft of changes "Default Workspace"
Version A saved snapshot of the container; each publish records one "v3 Add phone click event"

Nothing in a workspace affects the live site until you publish it, which is why Tag Manager is safer than editing site code directly.

A note on recent changes. In August 2026 Google announced that Google tags are being upgraded to full Tag Manager containers with a simplified interface, that the upgrade will not change the in-page behaviour of Google tags, and that optimisation is optional. Menus below may look slightly different in your account; if they do, follow the current help pages listed at the end.

Step-by-step instructions

Step 1: Start your Google Tag Manager setup with an account and container

  1. Go to tagmanager.google.com and sign in.
  2. Select the Accounts tab, then Create Account.
  3. Under Account Setup, enter an account name and choose a country.
  4. Under Container Setup, enter a container name. For a website, Google says to use the top-most URL, such as www.example.com.
  5. Choose Web as the container type, select Create and accept the terms.

Use one container per website.

What success looks like: You see an empty workspace with your container name and an ID that starts with GTM-.

Step 2: Install the container on every page

On the Workspace tab, select your container ID to open the Install Google Tag Manager dialog. It gives two snippets, and you must paste both:

<head>
  <!-- Snippet 1 (script): from your container, as high in the head as possible -->
</head>
<body>
  <!-- Snippet 2 (noscript iframe): from your container, immediately after the opening body tag -->
</body>

If you use WordPress, Shopify, Wix or a similar platform, Google says an integration can do this without editing each page, so check that first. In the dialog you can enter your site's address and select Test to confirm the container is found.

If your own code uses the data layer, declare it before the container snippet, as the data layer section below explains.

What success looks like: The page source of your home page contains both snippets with your own container ID, and the Test button finds the container.

Step 3: Add the Google tag for GA4

  1. In the Workspace tab, select Tags, then New.
  2. Replace "Untitled Tag" with a name such as "Google tag".
  3. Under Tag Configuration, choose the tag type Google Tag.
  4. Enter your Tag ID. Use the Measurement ID of your GA4 stream, which starts with G-.
  5. Under Triggering, choose Initialization - All pages.
  6. Select Save.

Google's instructions use the Initialization - All pages trigger for this tag. Older containers may show a tag type called Google Analytics: GA4 Configuration for the same job. Do not add both for the same stream, and check Google's current help before you change an existing tag.

What success looks like: The tag appears in your Tags list with the trigger Initialization - All pages.

Step 4: Remove the old direct snippet

If GA4 was installed with its own snippet or a plugin, only one method should send data. The order that loses least data is to confirm the container in Preview (Step 5), publish it (Step 6), then remove the direct snippet or plugin straight afterward. You accept a few minutes of double counting. Removing it first leaves a gap with no data instead.

The website launch SEO checklist includes making sure analytics tags are present once.

What success looks like: The page source contains the GTM snippets and no separate gtag/js loader for the same ID.

Step 5: Preview before you publish

  1. On the Workspace tab, select Preview at the top right. Tag Assistant opens in a new tab.
  2. Enter your site's address and select Connect. Your site opens in a new window and shows Connected.
  3. Return to the Tag Assistant tab and select Continue.
  4. Browse the site. The debug view shows whether each tag fired and which trigger caused it.

If the debug parameter breaks your site, Google says you can clear the option to include the debug signal in the URL. To stop, close the debug interface or select Stop debugging.

Then check GA4: DebugView and the Realtime report should show your visit. DebugView will not show events if consent mode applies and the visitor has not consented.

What success looks like: Tag Assistant says the Google tag fired on the page, and GA4 Realtime shows your visit.

Step 6: Publish a named version

  1. On the Workspace tab, select Submit at the top right.
  2. In Submission Configuration, choose Publish and Create Version. (Choose Create Version to save without publishing.)
  3. Enter a version name and a description.
  4. Select Activity History to review the changes.
  5. Select Publish.

Use names that say what changed:

Version name Description
v1 Install GA4 Added Google tag with Initialization - All pages
v2 Phone click event Added phone_click tag and trigger; tested in Preview

What success looks like: The Versions screen lists your published version, and the live site sends data to GA4.

Step 7: Add your first event

Pick one useful action, such as a click on the phone number. Build it in the workspace and preview it before you publish.

  1. Select Tags, then New. Name it "GA4 Event - phone click".
  2. Choose the tag type Google Analytics: GA4 Event, enter your Measurement ID, and set Event Name to phone_click. Google's example is a name like signup_newsletter. Custom event names are case sensitive, must start with a letter, must be fewer than 40 characters and cannot be a reserved name.
  3. Under Triggering, create a new Click trigger. Choose Just Links (clicks on HTML links) and limit it to some clicks only. Add the condition Click URL contains tel:. Make sure the Click URL built-in variable is enabled in your container.
  4. Save, then repeat Step 5 and click the phone link on your site. The tag should fire only on that click.

If the tag type names differ in your account, choose the Google Analytics event tag that Google's current help describes. For a form, Google's custom event trigger page describes pushing an event name to the data layer when standard form triggers do not work; if the form leads to a thank-you page, a Page View trigger on that page is simpler. Then mark the event as a key event in GA4 with the key events guide. If you tag campaign links, the UTM parameters guide explains naming.

What success looks like: In Preview, the event tag fires once per click, and GA4 DebugView shows phone_click.

Step 8: Set permissions and know how to roll back

Container permissions are No access, Read, Edit, Approve and Publish. Edit can make changes but cannot create versions or publish; Approve can create versions but not publish; Publish has full rights. Account permissions are Admin or User. Google advises keeping at least two admins, using individual logins and giving people the lowest level they need. If a container loses all admins it is deleted.

To undo a bad release, open Versions, choose the earlier version, and use Actions to select Set as Latest Version. That replaces your workspace draft with the old version and publishes nothing, so then submit and publish it. You can also publish an earlier version directly from the Versions screen.

What success looks like: At least two named people can administer the container, and you know how to restore the last good version.

What is the data layer?

The data layer is a JavaScript object that Tag Manager can read, so a tag can pick up values such as a page type or order total without scraping the page. You send information by pushing an object, and the event key names the event:

window.dataLayer = window.dataLayer || [];
dataLayer.push({ 'event': 'form_sent', 'form_name': 'quote' });

Declare the data layer before the container snippet, use one per page and never overwrite it after it is created. A developer adds the pushes; you then use a Custom Event trigger named form_sent.

Consent Overview, which you enable under Admin, Container Settings, Additional Settings, groups tags by whether consent settings are configured. Tags such as Google Analytics, Google Ads and Floodlight have built-in consent checks; Google's page says that under the default Not set option no additional consent checks are performed by a tag, so set them for every tag that needs one. Whether you need a banner depends on your country and visitors, and this is not legal advice. The consent mode guide explains the signals.

Final verification checklist

  • A Web container exists with the site's top-level address as its name.
  • Both snippets are on every template, with your own GTM- ID.
  • The Google tag uses your Tag ID and the Initialization - All pages trigger.
  • No second GA4 snippet is left in the code.
  • Preview showed each tag firing when it should and not otherwise.
  • GA4 Realtime shows test visits.
  • Each published version has a clear name and description.
  • At least two admins exist and publish rights are limited.
  • You tested the phone click or another real event.

Common mistakes to avoid

  • Leaving the old GA4 snippet in place. Visits and events are counted twice. Remove it when Tag Manager works.
  • Pasting only one of the two snippets. The noscript part belongs right after the opening body tag.
  • Publishing without Preview. Test every new tag on the live site first.
  • Vague version names like "update". Name what changed so you can roll back.
  • Sharing one login. Use individual accounts so you can see who changed what.
  • Giving everyone Publish. Use Edit or Approve for people who should not go live.

Frequently asked questions

Do I need Google Tag Manager to use GA4?

No. You can paste the Google tag directly or use a CMS field. Tag Manager helps when you expect to add or change tags, because you get Preview and versions.

Does Tag Manager slow down my site?

It adds a script, and the tags inside it add their own. Each tag you add has a cost, so remove tags you do not use and measure.

How do I know a tag really fired?

Use Preview. Tag Assistant shows whether each tag fired and which trigger caused it. Then confirm in GA4 DebugView or Realtime.

Can I undo a published change?

Yes. Open Versions, choose an earlier version, and set it as the latest, or publish it. Tag Manager records a version on every publish.

No. Tag Manager is a delivery tool. What your tags may do before consent depends on your configuration and on the law that applies to you, which is for a qualified adviser to judge.

Official references


Next step: Try the free website sample to see how your own site does on a few of these checks. This guide provides technical information, not a guarantee of rankings, traffic or index inclusion.