How to set up Google Tag Manager and GA4, step by step

GuideKovumoUpdated 2026-11-268 min read

Short answer

To set up Google Tag Manager, create an account and a web container at tagmanager.google.com, paste its two snippets into every page (one in the <head>, one right after <body>) or add the container ID in your CMS, then add the Google tag for GA4 on the Initialization – All Pages trigger. Test in Preview mode, check GA4 Realtime, and publish a named version.

  1. Create the account and container
  2. Install GTM on your site
  3. Add GA4 through GTM
  4. Test with Preview mode
  5. Publish and keep it tidy
  6. Common setup mistakes
  7. FAQ

Create the account and container

  1. Go to tagmanager.google.com and click Create account.
  2. Use your company name for the account and your domain for the container, for example example.com.
  3. Choose Web as the target platform and accept the terms.
  4. Copy the container ID, which looks like GTM-XXXXXXX. GTM also shows the two install snippets.

Create the account under a company Google account, and add colleagues and your agency as users in Admin → User management. A container owned by a freelancer's personal account is hard to recover later.

Install GTM on your site

SiteHow to install
Custom code or static sitePaste the <script> snippet as high as possible in the <head> and the <noscript> snippet right after the opening <body> tag, on every page
WordPressUse a GTM plugin (such as GTM4WP) and enter the container ID, or add the snippets to the theme header
WebflowSite settings → Custom code: the script in Head code, the noscript at the start of Footer code
FramerSite settings → General → Custom code: start of <head> and start of <body>
HubSpot CMSThe site header HTML field in your website page settings (the exact menu depends on your HubSpot version)

Install GTM once. A container added by both a plugin and the theme fires every tag twice. If the site has a Content Security Policy, allow www.googletagmanager.com for scripts and the Google Analytics domains for connections.

Add GA4 through GTM

  1. In GA4, open Admin → Data streams, select your web stream and copy the measurement ID (G-XXXXXXXXXX).
  2. In GTM, click Tags → New → Google tag and paste the measurement ID as the tag ID.
  3. Set the trigger to Initialization – All Pages, so the Google tag loads before any event tag.
  4. Remove any GA4 code hard-coded in the site or added by a plugin, or every page view will count twice.
  5. If you use a cookie banner, set up consent mode before going live.

Events for forms, bookings and downloads come next: see tracking form submissions and which key events a B2B site needs.

Test with Preview mode

  1. Click Preview in GTM and enter your site URL. Tag Assistant opens your site in a new window.
  2. In Tag Assistant, the Google tag should appear under Tags fired on the first event.
  3. In GA4, open Admin → DebugView: your session should show page_view events within a few seconds.
  4. Click around and submit a test form if you set up events; each should fire once.

Publish and keep it tidy

Common setup mistakes

FAQ

Is Google Tag Manager free?

Yes. The standard version of GTM is free. A paid version exists as part of Google Marketing Platform for large enterprises.

Do I need GTM if I only use GA4?

Not strictly: you can add the Google tag directly. GTM pays off as soon as you track forms, add an ad platform or want to change tracking without a developer.

What is the difference between GTM and GA4?

GTM loads and manages tags; it stores no data. GA4 is where the data is collected and reported. GTM sends events to GA4.

How long does a GTM setup take?

Installing the container and the Google tag takes under an hour. A full setup with forms, consent and ad platforms takes longer, mostly in testing.

Rather not set this up yourself?

We set up GA4, GTM and ad platform conversions on existing sites: GA4 setup from $450, each ad platform $200–$400.

See GA4 + GTM setup

Related

All guides