← All resources Tutorial

Installing GA4 with Google Tag Manager, step by step

The right way to put Google Analytics 4 on a website is one Google tag in Google Tag Manager, firing on every page before anything else. It takes ten minutes, and done this way every later addition, from key events to e-commerce to Consent Mode, is a change in Tag Manager instead of a change in the website's code. This article does exactly that, then shows the two checks that catch the installation mistakes that cause most GA4 problems: a tag that fires twice, and a tag that fires before consent.

You need a GA4 property with a web data stream (create one here if you have not) and a Tag Manager web container installed on the site (set one up here). Part of the GA4 setup guide, step 3.

Before you start: find the Measurement ID

In GA4 go to Admin › Data collection and modification › Data streams, open the web stream and copy the Measurement ID, the value that starts with G-. One stream, one ID; if you see two web streams for the same site, that is a mistake from an earlier attempt and you should use the one with data or delete the empty one.

Create the Google tag

In Tag Manager open the web container, go to Tags › New and pick Google tag as the tag type. Paste the Measurement ID in the Tag ID field. Leave the configuration settings and shared event settings empty for now; they are where you later add parameters that every event should carry, such as a user ID or a content group.

Name the tag something you will recognise in a year: Google tag · GA4 is better than GA4, because the same tag type also serves Google Ads.

Fire it on Initialization, not on Page View

Under Triggering choose the built-in Initialization - All Pages trigger. It fires before the regular Page View trigger, which guarantees that the Google tag has loaded by the time any GA4 event tag wants to send something. A Google tag on the ordinary All Pages trigger works most of the time and then randomly loses the first event on slow pages.

If you use Consent Mode (and in the EU you do), this is also where the Consent Initialization - All Pages trigger matters: your consent platform's tag goes on that one, so the default consent state exists before the Google tag runs. Order of events on every page: consent defaults, Google tag, everything else.

Save the tag. Do not publish yet.

Check it in Preview and Tag Assistant

Click Preview, enter your site's URL and let Tag Assistant open it. On the first page load you should see the Google tag under "Tags fired" exactly once, on the Initialization event. Click through to a second page: the tag fires again (it is a full page load) and nothing else happens.

Then switch to the GA4 side: Admin › DebugView in the property. Because Tag Assistant puts the browser in debug mode, your events appear here in real time. You are looking for one page_view per page you open, plus session_start and first_visit on the first one.

The double-install test

Before publishing, make sure the site does not already send GA4 data some other way. Open the site in a normal tab with the browser's network panel filtered on collect: every GA4 hit shows up as a request to a /g/collect URL. Load one page. One request with en=page_view is right. Two means a second installation, usually one of these:

Remove the extra one. Two page views per page is the single most common cause of GA4 numbers that are "too good" and bounce rates that are "too low". Measurebase's audit flags this as duplicate tracking; the duplicate tracking guide covers each source.

Publish and verify the next day

Submit the container with a version name that says what changed ("GA4 Google tag added"). The next morning, open Reports › Realtime while visiting the site from your phone on mobile data: you should see yourself. Then check Reports › Engagement › Pages and screens for yesterday: page titles and paths should look like your site, with views roughly matching what your server logs or your previous analytics showed.

Two numbers to sanity check in the first week: views per session (between 1.5 and 4 for most sites; 1.0 means the tag fires only on landing pages, 8 means it fires on something that is not a page) and the share of sessions from "(direct)" (above 50 percent on a site with campaigns usually means a tracking gap, not loyal visitors).

When you run GA4 through a server container

With server-side tagging the Google tag stays in the web container, with one extra field: under configuration settings, server_container_url points at your tagging server, for example https://mbase.yoursite.com, or your own domain's path when you use Same-Origin Tracking. The browser then sends the GA4 hits there instead of to Google, and the server container forwards them.

Everything in this article stays the same: one tag, Initialization trigger, DebugView, the double-install test. What you gain is covered in GA4 server-side: the basics. If you use Measurebase, the GTM template import creates this tag with the server URL already filled in, and the nightly audit checks that the URL is still right (the finding "Google tag has no server URL" is exactly this field missing).

Frequently asked questions

Google tag or GA4 Configuration tag: which one?

The Google tag. "GA4 Configuration" was the old name of the same tag type; Tag Manager migrated existing ones in 2023. If you still see a GA4 Configuration tag in an older container, it works, but new containers only offer the Google tag.

Do I need a separate GA4 event tag for page views?

No. The Google tag sends page_view itself. Event tags are for the extra events you define, such as a lead form submit. Adding a page_view event tag on top doubles your page views.

Why does DebugView show nothing?

Debug mode is only on while Tag Assistant is connected or when the page carries debug_mode: true. Close Tag Assistant and DebugView goes quiet, even though data still arrives in the normal reports a day later.

Can I install GA4 with Tag Manager on a single-page app?

Yes, but the Initialization trigger fires only on the first load. Virtual page views need a History Change trigger and a page_view event tag with send_page_view turned off on the Google tag, or the first page counts twice.

What if my shop platform already added GA4?

Pick one. Either remove the plugin's GA4 tag and keep Tag Manager (recommended when you want e-commerce events you control), or keep the plugin and do not add the Google tag in Tag Manager. Never both.

Does the Google tag set cookies before consent?

Only if consent defaults are not in place. With Consent Mode configured, the tag waits for the analytics_storage state and sets _ga only after consent is granted. Check with the browser's cookie panel on a fresh visit before accepting the banner.

Continue reading

Ready to move your tagging to Europe?

Start free, no credit card required. Live in about 15 minutes.

Start free