GA4 Setup: Step by Step with Google Tag Manager

04 AUGUST 20268 min readGoogle Analytics

GA4 Setup: Step by Step with Google Tag Manager

Installing GA4 takes 15 minutes. Installing it correctly takes an hour — and the difference decides whether the data you have a year from now is any use. This post shows the second option step by step.

Short answer

The order is: create a property → open a data stream → copy the measurement ID → add the Google Tag Manager container to the site → set up the Google tag in GTM → publish → check with DebugView. Then fix 6 important settings: raise data retention to 14 months, filter your own traffic, set the time zone and currency, mark key events, link Google Ads, and switch off unwanted referrals.

If you’re not familiar with the model itself, first read what GA4 is and how it works — here I assume you already know about events, properties and sessions.

3 decisions to make before installing

An analytics dashboard open on a monitor at a desk — setting up GA4
Setup is done once, but its result is used for years — so rushing is expensive.
  1. Whose name is the account opened in? Always open it with your own Google account, then give the agency access. A property opened in the agency’s account is lost when you part ways.
  2. One property, or several? One website = one property. If you have a mobile app, it should be the second data stream of the same property.
  3. Direct code, or Google Tag Manager? In practice, almost always GTM. I show why below.

Step 1 — Creating a property

Go to Google Analytics → Admin (the gear in the bottom left corner) → Create → Property. There are few fields to fill in, but two matter:

  • Reporting time zone: for Baku, (GMT+04:00) Baku (choose your own city if you’re elsewhere). If it’s set wrong, daily reports shift and comparison with ad accounts breaks.
  • Currency: the currency you sell in, for example AZN. If you change it later, past data isn’t recalculated — old numbers stay in the old currency.
Note

You can change the time zone later, but it doesn’t affect past data — it creates a break at the day boundary in reports. So set it correctly from day one.

Step 2 — Data stream and measurement ID

Admin → Data streams → Add stream → Web. Enter the website address (for example namigpashayev.com) and a name for the stream. The screen that appears shows the Measurement ID — a code starting with G-. Copy it; you’ll need it in the next step.

The same screen has the Enhanced measurement switch. Keep it on: scrolling, outbound link clicks, file downloads, internal site search and YouTube videos start being measured automatically.

Step 3 — Why Google Tag Manager?

There are two ways to connect GA4 to a website. The difference doesn’t show in the one-off setup but in every change afterwards.

Direct code (gtag.js)

  • Simple: you paste one block of code into the <head>
  • Every new measurement requires changing the site’s code
  • The Meta pixel and Google Ads tag are added separately
  • If something goes wrong, you need a developer again to roll it back

Google Tag Manager

  • Connected to the site once, then you don’t touch the code
  • New events, new pixels — all from the GTM panel
  • All measurement tools are managed in one place
  • There’s a version history: if something goes wrong, roll back in one click
  • You can test in Preview mode before publishing

Conclusion: if you’ll make more than one measurement change on your site — GTM. In practice, that means almost every website.

The path of the data looks like this:

Visitor

Opens a page, clicks a button, submits a form

→

Website · dataLayer

Information about the action is created

→

Google Tag Manager

A trigger checks it and fires the tag

→

GA4

The event is recorded and reaches the report

GTM is the “switchboard” of measurement: the site gives it information, and it passes that information to GA4, the Meta pixel and Google Ads in the form each needs.

Step 4 — Adding the GTM container to the site

tagmanager.google.com → create an account and a container (type: Web). You’ll be given two blocks of code. The placement rule is exact:

Placement rule
<!-- Block 1: AS HIGH AS POSSIBLE in the <head> tag -->
<head>
  <script>(function(w,d,s,l,i){...})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
  ...
</head>

<!-- Block 2: IMMEDIATELY AFTER the <body> tag -->
<body>
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"></iframe></noscript>
  ...

WordPress, Shopify and similar platforms have a built-in field or plugin for this — there’s no need to edit the code by hand.

Setting up the Google tag in GTM

Inside the container: Tags → New → Tag Configuration → Google Tag. The only field to fill in is the measurement ID. For the trigger, choose Initialization – All Pages.

Google Tag Manager › Tags › GA4 — Google Tag

Tags

Triggers

Variables

Folders

Templates

Preview

FieldValue

Tag typeGoogle Tag

Tag IDG-XXXXXXXXXX

TriggerInitialization – All Pages

Tag nameGA4 — Google Tag

The whole setup is these four rows. Important: the trigger should be “Initialization – All Pages”, not “All Pages” — that way GA4 loads before other tags.

Then Submit → Publish. Until you publish, changes don’t go live on the site — this is the most forgotten step in GTM.

Step 5 — Checking the setup

There are three separate checks, and you need all three:

  1. GTM Preview. The Preview button in GTM opens the site in a separate window and shows which tag fired.
  2. GA4 Realtime. Reports → Realtime — when you visit the site yourself, you should appear there. It’s the fastest proof that data is reaching GA4.
  3. DebugView. The most precise tool: Admin → DebugView. When GTM Preview mode is on, your device appears here and every event is shown second by second, together with its parameters.
GA4 › Admin › DebugView — device stream

Seconds stream

Events

page_view

scroll

form_submit

User properties

EventTime

session_start0:00

first_visit0:00

page_view — /en/services0:01

user_engagement0:12

scroll — 90%0:24

form_submit0:51

In DebugView you can click any event to see its parameters. The test rule: if an event doesn’t appear here, it will never appear in the reports either — solve the problem right here.

If you visit the site and see nothing, check in order: has GTM been published → is the measurement ID correct → is an ad blocker running in the browser?

6 settings you must change after installing

SettingWhereWhy
Raise data retention to 14 monthsAdmin → Data settings → Data retentionThe default is 2 months. This setting affects Explorations and funnel reports — with 2 months you can’t compare with the same period last year
Filter internal trafficAdmin → Data streams → Configure tag settings → Define internal trafficYour own IP spoils the report — especially on a new site
Switch off unwanted referralsConfigure tag settings → List unwanted referralsPayment systems (the bank page) create a new session and “steal” the source of the sale
Mark key eventsAdmin → Events → “Mark as key event”Without this, GA4 doesn’t know what counts as success
Link your Google Ads accountAdmin → Product links → Google AdsCampaign data flows into GA4 and audiences flow into Ads
Link Search ConsoleAdmin → Product links → Search ConsoleOrganic search queries appear in GA4 reports
The most important item

Data retention. This setting should be changed in the first minute after installing, because it doesn’t work retroactively: if you raise it to 14 months after 2 months have passed, the lost data doesn’t come back.

The 5 most common mistakes

  1. GA4 connected twice. Both in the site template and in GTM. The result: every pageview is counted twice and the bounce rate drops artificially. Check: if you see two page_view events for one page load in DebugView — this is the problem.
  2. GTM not published. The panel looks full, but the site sends nothing. Submit → Publish was forgotten.
  3. Not filtering your own traffic. If you visit your own site 40 times a day, all the numbers for the first months are you.
  4. Not measuring the thank-you page. The form is submitted, but no event is recorded. It’s unclear which ad brought the lead.
  5. Counting the payment system as a referral. When the buyer goes to the bank and comes back, GA4 records them as “a new visitor, source: bank website”. The fix — the unwanted referrals list.

The order for day one

1

Property and data stream

Correct time zone, your currency, enhanced measurement on.

2

GTM container on the site

Two blocks, in the head and the body. Then the Google tag + Initialization trigger.

3

Publish and check

Publish → see yourself in Realtime → read the events in DebugView.

4

Fix the 6 settings

Especially data retention — 14 months.

5

Set up your own events

Form, call and WhatsApp clicks. See: events and dataLayer. And to read the numbers, the reports guide.

Setup is an hour’s work; the result of a bad setup is a year of useless data. That ratio is worth keeping in mind.

Can GA4 be installed without Google Tag Manager?

Yes — by putting the measurement ID directly in the site’s <head> or using the built-in field of platforms like WordPress/Shopify. But afterwards, for every new measurement (button click, form, video) you’ll have to touch the site’s code. GTM removes that need entirely.

What happens if I put the GA4 code both on the site and in GTM?

Every pageview is counted twice: pageviews inflate, the bounce rate drops artificially and the session count is distorted. You detect it by seeing two page_view events in DebugView when you open one page. The fix: remove one of them completely.

How long until data appears?

In the Realtime report, immediately — within a few seconds. In standard reports, full processing of the data usually takes 24 hours. So there’s no need to worry that “yesterday’s numbers are low”; wait a day.

How do I exclude my own visits?

Two steps are needed: first, record your IP address under Admin → Data streams → Configure tag settings → Define internal traffic, then switch that filter to “Active” under Admin → Data settings → Data filters. Doing only the first step isn’t enough — the filter is in testing mode by default.

An event shows in DebugView but not in the report — why?

Usually the reason is time: standard reports show data with a delay of up to 24 hours. If it’s still missing a day later, the likely causes are a difference in upper/lower case in the event name (GA4 event names are case-sensitive) or a wrongly configured filter.

How many websites can one GTM container measure?

It’s technically possible, but not recommended. Keeping a separate container for each site is safer: an error on one site doesn’t break another, access permissions are easy to separate and the tag list doesn’t get mixed up.

How much do ad blockers make GA4 under-report?

It depends on the audience — losses are higher on tech-focused sites. There isn’t an exact figure, but the point is that this loss affects all channels roughly equally, so comparisons stay reliable. For more precise measurement there’s the server-side tagging option — I explained it in the advanced post.

Conclusion

Setting up GA4 has two parts: connecting the code (the easy part) and fixing the settings (the real work). Those who skip the second end up a year later with 2 months of data, fake traffic created by their own IP, and reports that don’t show which ad brought customers.

The next step is setting up your own events: GA4 events and the dataLayer. If you’d like me to do the setup for you — see the analytics and tracking page or fill in the get a quote form.

Source: Google official documentation — setting up the Google tag, DebugView, data retention.

Share

Namig Pashayev

Digital marketing specialist. Works on advertising, analytics and tracking, and writes here about what he sees in practice.

Need help with this topic?

Tell us what you need. We'll review your ad accounts and website and send a written proposal within 5 business days. The audit is free.