Choose a language

Web team reviewing an analytics dashboard on a laptop

How to Set Up GA4 with Google Tag Manager

Published November 5, 2026 · Mis à jour le November 16, 2026 · 17 min read

Google Tag Manager and GA4 are not two versions of the same thing. GTM is the container that deploys and manages tags on your site, and GA4 is the platform that receives, stores, and reports the data. You need both, and the setup has a fixed order: property and data stream first, tag second.

This guide walks the whole path in the order you will actually do it. First the mental model, then the install in GTM, then the checks in GA4 that catch bad or missing data before you trust a single report.

The path in 7 steps

The steps of this page, in order.

  1. 01 Understand the split GTM deploys tags, GA4 stores and reports what they send.
  2. 02 Create the property Set up the GA4 property and web data stream before touching GTM.
  3. 03 Build the tag Add the Google tag in GTM and fire it on every page.
  4. 04 Test and publish Preview the container, confirm the tag fires, then publish.
  5. 05 Verify the data Check DebugView and Realtime to prove hits arrive.
  6. 06 Audit the settings Review retention, internal traffic, referrals, and conversions.
  7. 07 Decide who owns it Keep routine changes in-house and bring in help for the complex parts.

01 / 12

Is Google Tag Manager part of Google Analytics?

No. They are two separate Google products that do two separate jobs, and both are free to use at the standard tier.

Google Tag Manager (GTM) is a tag management system: it holds the code that runs on your pages and decides when each tag fires. A tag is a snippet of code that sends information somewhere, such as a pageview to GA4. A container is the GTM file you publish on your site; it holds all your tags and the rules for when they fire.

GA4 is the analytics platform: it receives the hits, stores them, and produces the reports you read. Neither replaces the other. A GA4 property with no tag sends nothing, and a GTM container with no GA4 destination collects nothing.

Developer checking tags in a code editor on a laptop

02 / 12

What's the difference between the Google tag and gtag.js?

The Google tag is what you deploy today; gtag.js is the older code you no longer need if you use Tag Manager.

The Google tag is the single tag that sends data to your Google destinations, including GA4. Google's documentation notes that the old GA4 Configuration tag has been replaced by the Google tag, and existing configuration tags were automatically upgraded while event tags stayed the same. If you use GTM, you deploy the Google tag inside a container and skip the snippet entirely.

gtag.js is the legacy snippet you paste directly into your site's HTML. It only sends data to Google services and does not support third-party or custom tags, so it becomes a dead end the moment you want to track something non-Google. Google's recommended path is Tag Manager because it lets you add, edit, or pause tags without touching site code.

Going further

Read the rationale

03 / 12

What do I need before I start?

Three things: admin access to the site, a Google account with edit rights on GTM, and a decision about who on the team owns tracking changes.

You need the ability to paste one container snippet into every page, usually through your CMS theme, a header plugin, or your host's settings panel. The container is the GTM file you publish on the site; it holds all your tags and the rules for when they fire.

Decide who owns the container. GTM lets you assign edit and publish permissions to a named person, so tracking changes do not queue behind a developer. Then follow one order: GA4 property and data stream first, the tag in GTM second.

Admin access to the site

You must be able to edit the site header or install a plugin, otherwise the container snippet has nowhere to go.

A Google account with GTM edit rights

You also need edit access to the GA4 property. Publishing rights are separate, so confirm you hold both.

A named owner for tracking

Pick the person who approves and publishes tag changes. GTM assigns permissions per person, not per agency.

A staging site, if you have one

Test the container there first so a broken tag never reaches live pages.

04 / 12

Should I create the GA4 property first or the GTM tag?

Always the property first. The tag needs a measurement ID that only exists once the property and its web data stream are created.

In GA4, create the property, then add a data stream, the GA4 connection to one source of data, such as your website. Copy the measurement ID it generates, usually formatted as G-XXXXXXXXXX.

Only then open GTM, create a Google tag, paste that ID, and attach the trigger that fires on all pages. Reversing the order means editing the tag again later, once the ID exists.

  1. Create the GA4 property

    In your Google Analytics account, create a new property and set the reporting time zone and currency. Who: the marketer or analyst with account access.

  2. Set up the web data stream

    Add a data stream for your domain, then open its details and copy the measurement ID. Who: same person, still inside GA4.

  3. Create the Google tag in GTM

    Open your GTM container, create a new Google tag, and paste the measurement ID into the Tag ID field. Who: whoever maintains the container.

  4. Add the all-pages trigger

    Attach a trigger that fires on every page view, such as the built-in All Pages trigger. Who: same GTM user.

  5. Test in Preview mode

    Use GTM Preview, load your site, and confirm the Google tag fires once per page load. Who: the person who created the tag, working with a browser session on the live site.

  6. Publish the container

    Once Preview shows the tag firing correctly, publish the container and verify data arriving in GA4 Realtime. Who: the same GTM user.

Analyst checking a tag list against a printed checklist

Going further

Show the reason

05 / 12

Which trigger makes the tag fire on every page?

An All Pages trigger. If you pick anything else, the tag fires only on some pages and your reports silently go partial.

An All Pages trigger in GTM is the condition that tells a tag to fire on every page view. It's the default pairing for the Google tag, so keep your pageview tag scoped to it alone. If you attach it to a single page or a form-submit trigger, only those pages send data.

When you need clicks, scrolls, or form submissions, add a second trigger to a new tag instead of widening All Pages. This keeps the pageview clean and makes it obvious which tag is responsible when numbers look wrong.

06 / 12

Do I have to use preview mode, or can I publish?

Preview first, publish second. Publishing without previewing is how duplicate tags and broken tags reach production.

Preview mode loads your site with the unpublished container, the GTM file that holds your tags and the rules for when they fire, so you can see exactly which tags trigger, page by page, before any real visitor is affected. A tag that stays in preview only never reaches your live site, so reports look empty and people start re-adding tags, which is how duplicates are born.

The classic failure is a double-counted pageview: two Google tags in one container, or a hard-coded Google tag sitting on top of your GTM one. Both fire on every page, and GA4 logs each visitor twice.

Duplicate Google tag

Two GA4 tags in the same container, or one hard-coded tag plus the GTM version, double every pageview. Check the Tags list in preview and confirm only one GA4 configuration tag fires per page.

Tag stuck in preview only

A tag tested but never published sends nothing to real visitors. After preview passes, publish the container and verify the tag fires again on the live site.

Your own domain as a referral

If GA4 lists your domain as a referral, sessions split and look like two visits. Add your domain to the unwanted referrals list in GA4 admin.

Firing on the wrong pages

A trigger set to All Pages fires everywhere, including staging or thank-you pages you meant to exclude. Walk through two or three page types in preview and confirm the tags you expect.

07 / 12

How do I know the data is actually arriving?

DebugView and Realtime. Do not assume the install worked because the container published cleanly.

DebugView shows events live from your own device while preview mode is on, confirming the tag fired and GA4 accepted it. If it stays empty, the tag did not fire.

Then check Realtime without preview mode. If it stays flat, verify the measurement ID matches the property you are viewing.

  1. Check the preview banner

    In GTM, click Preview, load your site, and confirm the orange banner appears. A pass means the container is connected and listening.

  2. Open DebugView

    In GA4, go to Admin > DebugView. With preview mode active, trigger a pageview. A pass means your event appears within seconds.

  3. Open Realtime

    Still in GA4, open Reports > Realtime. Without preview mode, visit your site from another device. A pass means the hit shows up for the whole site.

08 / 12

What GA4 settings should I check after install?

Four settings decide whether the data is usable six months from now: data retention, internal traffic, unwanted referrals, and conversions.

GA4 keeps only a limited history of user-level data, so your retention window decides how far back you can dig when someone asks what happened last year. Changing it later does not recover what was already dropped, which is why it is the first setting to check.

Internal traffic filters keep your own team’s visits out of the reports; unwanted-referral exclusions stop payment or login domains from ending real sessions. Conversions decide what counts as a goal, and if pageview is the only event, nothing in your funnel will ever register.

Post-install settings audit

SettingWhat it controlsUsual defaultWhere to find it
Data retentionHow long user-level data stays available for exploration2 monthsAdmin > Data collection and modification > Data retention
Internal trafficExcludes your team's visits from reportsOffAdmin > Data streams > Configure tag settings > Define internal traffic
Unwanted referralsStops payment or login domains from ending real sessionsEmpty listAdmin > Data streams > Configure tag settings > List unwanted referrals
ConversionsMarks events that count as goalsNoneAdmin > Events > Mark as conversion

Check each of these after the GA4 tag is live. The defaults are the GA4 out-of-the-box values; adjust them to match your business.

Going further

About retention

09 / 12

How do I stop the same pageview being counted twice?

Check for two GA4 tags in the same container, a hard-coded tag still in your site theme, and a tag firing on more than one trigger.

Duplicate pageviews usually come from two sources: a tag (a snippet of code that sends information somewhere, such as a pageview to GA4) that exists both in your container and on the site itself. The other is a single container holding two nearly identical tags, often from an imported template.

You don't need to guess. Open preview mode and watch which tags fire on one page load. Two identical pageview tags on the same page is the answer.

Container tags

Open your GTM container and look for two Google tags sending pageviews to the same GA4 measurement ID. A copied workspace or imported template is the usual origin. Delete the duplicate, then republish.

Hard-coded snippets

Search your site's theme or header file for a leftover gtag.js snippet. gtag.js is the older direct code you paste into your site; it only sends data to Google services. If it's still there alongside your GTM tag, every pageview is counted twice.

CMS plugins

Check your CMS plugin list for anything that injects a Google Analytics tag on its own, such as an SEO or analytics plugin. Disable that injection or point the plugin at GTM instead.

Trigger overlap

In GTM, confirm the pageview tag fires on the All Pages trigger only. A second trigger like a scroll or click trigger on the same tag will fire it again mid-session.

10 / 12

Can I do this myself or should I hire someone?

The basic install is a marketer job. The moment you need a data layer, consent handling, or server-side tagging, bring in help.

Keep it in-house for the Google tag, the All Pages trigger, preview and publish, DebugView checks, and the settings audit. Those tasks are configuration work a marketer can run in an afternoon without touching code.

Bring in help once you need a data layer (a shared place on the page where your site writes information that tags can read), e-commerce events, consent mode configuration, server-side containers, or anything that touches legal questions about user data. Remember that GTM only deploys tags while GA4 stores and reports the data, so neither replaces the other.

11 / 12

Frequently asked questions

Frequently asked questions

12 / 12

Sources, data and disclaimer

The Web Insider editorial team
About the author The Web Insider editorial team

Web Insider is a practical magazine for people who build, run or grow a website. Every fact is checked against its official source, and every test shows its proof.

Your feedback

Was this page helpful?

Share

Could this page help someone?

Related reading

Read next

Laptop on a desk showing an analytics dashboard and code next to sticky notes
Data & Analytics

What Is Google Tag Manager? A Plain-English Guide

Google Tag Manager (GTM) is a free tool that lets you add and manage marketing and analytics tags on a site without touching code. This guide explains tags, triggers, and variables, how GTM works with GA4, and whether you need it.

·13 min
Abstract tag management interface on a laptop, with no logo visible
Data & Analytics

Google Tag Manager Logo: What the Icon Means

The GTM logo is the interlocking double-diamond mark for Google's tag management product. It proves Tag Manager is attached, not that your tags work. Here's how to read it.

·13 min
Laptop showing a tag debugging panel on a desk with a coffee mug
Data & Analytics

Best GTM Chrome Extensions for Testing Tags

Tag Assistant Legacy is gone, and the current crop of GTM Chrome extensions splits into three jobs: debugging tags, inspecting the dataLayer, and validating pixels. This guide maps each extension to the task you're actually doing.

·17 min
Explore the topicData & Analytics

Audience measurement, Google Analytics 4 and Google Tag Manager: set them up, check them and keep your data reliable.

Explore the topicWebsites & Platforms

WordPress, Shopify, PrestaShop and WooCommerce: run, integrate and maintain a site without making it fragile.

Explore the topicGuides & How-Tos

Methods, training and practical benchmarks to scope a web project, test a site and make better decisions.

Explore the topicSecurity & Compliance

Backups, updates, GDPR, cookies and audience measurement: keep a site safe and compliant.