Skip to content

Web and product analytics

How to set up Google Tag Manager (and GA4 through it)

By the editors of Analytics1.comLast reviewed 19 October 20263 min read

The short answer

Create a Tag Manager account and one Web container per website at tagmanager.google.com, paste the container's two snippets into every page (one high in the head, one straight after the opening body tag), then add a Google tag with your GA4 measurement ID firing on all pages. Check it in Preview mode with Tag Assistant, and nothing goes live until you click Submit and publish a version.

On this page 6 sections
  1. What Tag Manager is for
  2. Step by step
  3. How to keep a container tidy
  4. What to set up next
  5. Questions
  6. Sources

What Tag Manager is for

Google Tag Manager (GTM) is a container for tracking code. You install one snippet once, then add, change and remove tags (GA4, Google Ads conversions, Meta, LinkedIn, call tracking scripts) from the GTM interface without editing the site each time. Every change is versioned, so a bad change can be rolled back in a minute. For a site with one GA4 tag and nothing else, GTM is optional. Once a second or third tag arrives, or a marketer needs to change tracking without a developer, it pays for itself.

Step by step

  1. Sign in at tagmanager.google.com, open the Accounts tab and choose Create Account. Use your organisation as the account, and set the country.
  2. Create one container per website. Google suggests naming it after the site's top-level URL. Choose Web as the container type, then Create, and accept the terms.
  3. Install the container. GTM shows two snippets: the script goes as high in the <head> of every page as possible, and the <noscript> iframe goes immediately after the opening <body> tag. On WordPress, Shopify and most site builders there is a setting or a plugin for this; do not paste the code into a single page template that some pages skip.
  4. Add GA4. In the Workspace, create a new tag of type Google tag, enter your GA4 measurement ID (it starts with G-), and set the trigger to Initialization - All Pages (or All Pages). If the site already has a hard-coded GA4 tag, remove it, or you will count every page view twice.
  5. Click Preview. Tag Assistant opens in a new tab; enter your site's URL and Connect. Your site opens showing Connected, and the Tag Assistant tab lists every tag that fired on each page and event. If the debug parameter breaks your site, untick Include debug signal in the URL.
  6. With Preview still running, open GA4's DebugView (Admin, then DebugView) and confirm page_view and session_start arrive.
  7. Click Submit, give the version a name that says what changed ("GA4 base tag, removed hard-coded gtag"), and Publish. Until you publish, only Preview sees your changes.

How to keep a container tidy

  • Name things by pattern: "GA4 - Event - generate_lead", "Trigger - Form - Quote form". Six months from now someone else will read it.
  • One person publishes. Workspaces let several people prepare changes, but conflicting publishes are the usual cause of tags vanishing.
  • Use the data layer for business data. Ask developers to push values such as form name, plan or order value into window.dataLayer, then read them with Data Layer Variables, rather than scraping the page with CSS selectors that break on the next redesign.
  • Consent first. In regions that need consent, tags must respect the visitor's choice. GTM's consent settings and Consent Mode are covered in GA4 Consent Mode v2.
  • Agencies: work in the client's own account, as a user. If the container sits in the agency's account, the client loses its tracking history when the relationship ends.

What to set up next

With the base tag live, add the events that matter: form submissions (how to track form submissions in GTM), phone-number clicks, and purchases (GA4 ecommerce tracking). Then exclude your own team's traffic before anyone reads a report.

Questions

Is Google Tag Manager free?
Yes. Google Tag Manager is free. A paid Tag Manager 360 tier exists for large organisations as part of Google Marketing Platform, but small and mid-size sites use the free version.
Where do the Google Tag Manager snippets go?
The script snippet goes as high as possible inside the <head> of every page, and the <noscript> snippet goes immediately after the opening <body> tag. Both must be on every page you want to measure.
Do I need GTM if I already have GA4 installed?
Not for GA4 alone. GTM becomes worth it once you run several tags (ads conversions, call tracking, other pixels) or want marketers to change tracking without a code release. If you move GA4 into GTM, remove the hard-coded tag so page views are not counted twice.

Sources

Next step

Explore web analytics

Related guides