How to set up Google Tag Manager and GA4, step by step
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.
- Create the account and container
- Install GTM on your site
- Add GA4 through GTM
- Test with Preview mode
- Publish and keep it tidy
- Common setup mistakes
- FAQ
Create the account and container
- Go to tagmanager.google.com and click Create account.
- Use your company name for the account and your domain for the container, for example
example.com. - Choose Web as the target platform and accept the terms.
- 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
| Site | How to install |
|---|---|
| Custom code or static site | Paste the <script> snippet as high as possible in the <head> and the <noscript> snippet right after the opening <body> tag, on every page |
| WordPress | Use a GTM plugin (such as GTM4WP) and enter the container ID, or add the snippets to the theme header |
| Webflow | Site settings → Custom code: the script in Head code, the noscript at the start of Footer code |
| Framer | Site settings → General → Custom code: start of <head> and start of <body> |
| HubSpot CMS | The 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
- In GA4, open Admin → Data streams, select your web stream and copy the measurement ID (
G-XXXXXXXXXX). - In GTM, click Tags → New → Google tag and paste the measurement ID as the tag ID.
- Set the trigger to Initialization – All Pages, so the Google tag loads before any event tag.
- Remove any GA4 code hard-coded in the site or added by a plugin, or every page view will count twice.
- 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
- Click Preview in GTM and enter your site URL. Tag Assistant opens your site in a new window.
- In Tag Assistant, the Google tag should appear under Tags fired on the first event.
- In GA4, open Admin → DebugView: your session should show
page_viewevents within a few seconds. - Click around and submit a test form if you set up events; each should fire once.
Publish and keep it tidy
- Click Submit, give the version a name that says what changed ("GA4 base tag + consent"), and publish.
- Name tags as platform – type – detail:
GA4 – event – generate_lead,LinkedIn – conversion – demo form. - Use folders per platform once you have more than ten tags.
- Every published version can be restored, so roll back instead of editing in a panic.
Common setup mistakes
- Two installs: GTM in the theme and in a plugin, or GA4 both in GTM and hard-coded.
- Snippet only on some pages: landing pages built outside the main template often miss it.
- Changes not published: Preview works, the live site does not, because the workspace was never submitted.
- Ad tags without consent checks: LinkedIn and Meta tags firing before the visitor agrees.
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