Skip to main content
← Back to blog

How to Set Up Google Tag Manager Properly (Without Breaking Your Data)

27 July 20269 min read

How to Set Up Google Tag Manager Properly (Without Breaking Your Data)

A good Google Tag Manager setup is mostly about discipline: one container, installed once, with tags that fire exactly when they should and nowhere else. Most broken GTM setups we audit are not caused by anything exotic. They come from duplicate tags, hardcoded scripts left behind, vague triggers and changes published without testing.

This guide walks through how to set up Google Tag Manager properly, in the order we would do it, with the checks that stop you breaking your data along the way.

Quick answer

To set up Google Tag Manager properly: create one account and one web container per website, install both container snippets on every page, remove any hardcoded GA4 or ads tags it will replace, add a Google tag for GA4 with your measurement ID, configure consent before any marketing tags fire, build events with specific triggers, test everything in Preview mode and GA4 DebugView, then publish with a named, described version.

Before you start: plan what you need to track

Do not open GTM first. Open a document. Write down:

Planning Google Tag Manager setup strategy on paper before starting container work
  • Business goals: what counts as a lead or sale (form submission, call click, purchase, booking).
  • Platforms: GA4, Google Ads, Meta, LinkedIn, Microsoft Ads, Microsoft Clarity, your CRM.
  • Events: the specific user actions you need, and which platforms need each one.
  • Consent: which cookie banner or consent management platform (CMP) you use and how it will talk to GTM.

This short measurement plan becomes your naming reference and your testing checklist. Without it, containers grow into a pile of tags nobody understands.

Step 1: Create the account and container

  1. Go to tagmanager.google.com and create an account named after the business, not the agency or a person.
  2. Create a Web container named after the domain.
  3. Add users with sensible permissions. Give "Publish" rights to as few people as possible.

Ownership matters. The account should sit under the business's own Google login, with agencies added as users. If an agency leaves, the client keeps the container and its history.

Step 2: Install the container code correctly

GTM gives you two snippets:

  • The `<script>` snippet, placed as high in the `<head>` as possible.
  • The `<noscript>` snippet, placed immediately after the opening `<body>` tag.

On WordPress, Shopify and most site builders you can use a theme setting, an official integration or a reputable plugin instead of editing templates. Whatever the method, check that:

  • The container appears on every page, including thank you pages, checkout steps and landing pages built in separate tools.
  • It is installed once. Two copies of the same container mean every tag fires twice.
  • The container ID (GTM-XXXXXXX) matches the one you are editing.

Remove what GTM replaces

This is the step people skip. If your site already has a hardcoded GA4 tag, a Google Ads tag or a Meta pixel in the theme, and you add the same tags in GTM, you will double count page views and conversions. Search the page source for `gtag(`, `G-`, `AW-` and `fbq(` and remove anything GTM is taking over. Also check for plugins that add their own tracking.

Step 3: Set up GA4 through GTM

For a clean GA4 setup:

  1. In GA4, go to Admin, Data streams, choose your web stream and copy the measurement ID (G-XXXXXXXXXX).
  2. In GTM, create a new tag of type Google tag, paste the measurement ID as the tag ID, and set it to fire on Initialization - All Pages (or All Pages if you are not using consent initialisation).
  3. Decide on enhanced measurement. GA4 can automatically collect scrolls, outbound clicks, site search, video engagement, file downloads and form interactions. The automatic form interactions are often unreliable, so many setups turn that one off and track forms deliberately instead.

Store the measurement ID in a Constant variable so you only have to change it in one place.

Step 4: Configure consent before anything else fires

If you serve users in the UK or EEA, consent is not optional. With Google Consent Mode v2, your CMP tells Google tags whether the user has granted `ad_storage`, `analytics_storage`, `ad_user_data` and `ad_personalization`.

  • Basic consent mode: Google tags do not load at all until the user consents.
  • Advanced consent mode: tags load with default "denied" states and send cookieless pings, which Google uses for conversion and behavioural modelling.

In GTM, set default consent states on the Consent Initialization - All Pages trigger (most CMPs provide a template that does this), and make sure non-Google tags such as Meta or LinkedIn only fire once the relevant consent is granted. You can review each tag's consent settings in the container's consent overview.

Step 5: Build events with specific triggers

Each event in your measurement plan needs a tag and a trigger. The quality of your data depends on the triggers.

Use reliable signals

In rough order of reliability:

  1. A dataLayer push from the website or form plugin when something genuinely happens (for example, a successful form submission or a completed order).
  2. A thank you page view with a unique URL that only appears after success.
  3. Element Visibility of a success message.
  4. Click or form submission triggers based on CSS selectors, which can break whenever the site is redesigned.

Keep triggers narrow

"All Clicks" or "All Forms" with no conditions is how you end up counting newsletter sign-ups as leads. Add conditions such as Page Path, Form ID or Click URL so each trigger fires only on the action you mean. Our guide to tracking form submissions in GA4 with GTM goes through the options in detail.

Use GA4 recommended event names

Where one exists, use Google's recommended event name: `generate_lead`, `sign_up`, `purchase`, `begin_checkout`. It keeps reports consistent and unlocks some built-in features. Use lowercase with underscores for custom events.

Step 6: Add advertising tags

For Google Ads, add the Conversion Linker tag on all pages, then a Google Ads Conversion Tracking tag for each conversion action, using its conversion ID and label. Consider enhanced conversions, which send hashed first-party data such as email address to improve matching. Alternatively, import GA4 key events into Google Ads, but pick one primary source per conversion so you do not count the same action twice.

For Meta, LinkedIn and others, use their official or community templates in the Template Gallery, linked to the same triggers as your GA4 events.

Step 7: Name and organise everything

A consistent naming convention makes a container auditable. A simple pattern works:

  • Tags: `GA4 - Event - generate_lead`, `Google Ads - Conversion - Contact Form`
  • Triggers: `CE - form_success`, `PV - Thank You Page`
  • Variables: `DLV - form_id`, `CONST - GA4 Measurement ID`

Use folders for each platform, and delete paused tags you no longer need.

Step 8: Test before you publish

Never publish untested changes.

Preview mode and Tag Assistant testing a Google Tag Manager container setup
  1. Click Preview in GTM to open Tag Assistant and browse the site.
  2. Perform each action in your plan and confirm the right tags fire once, and only once.
  3. Check that tags respect consent: reject cookies and confirm marketing tags stay blocked.
  4. In GA4, open Admin, DebugView and confirm the events and parameters arrive.
  5. Test on mobile and in more than one browser.

Step 9: Publish with version notes

When you publish, give the version a name and a description of what changed. If something goes wrong, you can see exactly which change caused it and roll back to a previous version in a couple of clicks.

Then mark the right events as key events in GA4 (Admin, Events or Key events), and check reports over the next 24 to 48 hours, since standard reports are not real time.

Common GTM setup mistakes

Common Google Tag Manager setup mistakes to avoid during auditing
  • Container installed twice, or alongside hardcoded tags, causing duplicate data.
  • Container missing from checkout, booking or third-party landing pages.
  • Consent not wired up, so tags fire before consent or never fire at all.
  • Broad triggers that count the wrong actions as conversions.
  • Too many people with publish rights and no version notes.
  • UTM-tagged internal links overwriting session sources (see our UTM parameters guide).

When to bring in a GTM consultant

A DIY setup is realistic for a simple brochure site. It is worth getting a GTM consultant or specialist involved if you run ads with meaningful spend, have ecommerce or multi-step forms, use several platforms or a CRM, or need consent configured correctly for UK GDPR. The cost of a misconfigured container is usually invisible until you make a budget decision based on bad numbers.

If you would rather have it done once and done properly, our Tracking Setup (GTM & GA4) covers the container, event and conversion tracking, GA4 configuration and integrations with ads, forms and your CRM.

FAQs

Do I still need GA4 code on my site if I use GTM?

No. If GTM loads your GA4 Google tag, you should remove any hardcoded GA4 code. Running both will duplicate your data.

Can I use GTM on Shopify or WordPress?

Yes. Both support GTM, though Shopify checkout tracking works differently and usually relies on Shopify's customer events or native integrations rather than the standard container snippet.

How long does a proper Google Tag Manager setup take?

For a typical lead generation site, planning, building and testing takes a few hours to a day. Ecommerce, multiple platforms and consent configuration add time.

Is GTM free?

Yes, the standard web version of Google Tag Manager is free. Server-side tagging is also free in GTM itself, but you pay for the server hosting it runs on.

Get it set up properly

Want a clean, tested Google Tag Manager setup without the guesswork? Our Tracking Setup (GTM & GA4) is a fixed £149, or if you already have a container and are not sure you can trust it, our Tracking Audit + Fix is £199. Get My Audit and we will take it from there.

Share