If you manage a website or online store, you'll eventually run into Google Tag Manager (GTM). It's a tool that can save you a lot of time — but set up incorrectly, it can just as easily throw your analytics data into chaos. Here's what GTM actually does, how to set it up properly, and how to use it to track something concrete, like a form submission.
What is Google Tag Manager?
Google Tag Manager is a free tool from Google for managing all your tracking and marketing codes ("tags") in one place, without editing your website's code every time. Instead of manually adding Google Analytics, Facebook Pixel, or ad conversion codes to your pages, you add a single GTM container to your site once. Everything else is then managed through GTM's own interface, without touching the site's code and without waiting on a developer every time you want to add a new tracking snippet.
Google Tag Manager vs. Google Analytics: what's the difference?
These two get mixed up often. Google Analytics (now GA4) collects and analyzes traffic data — how many visitors came, where from, what they did on your site. Google Tag Manager doesn't collect or analyze any data itself — it's the delivery mechanism you use to deploy other tools' codes, including Google Analytics. Think of GTM as the wiring box, and GA4 as one of the devices plugged into it. Without GTM, you'd have to manually add and manage the code for GA4 — and every other tool — directly in your website's files.
What kinds of tags can you manage through GTM
Most people start with Google Analytics, but the possibilities go much further. Commonly deployed through GTM:
- Google Analytics 4 — tracking traffic and user behavior.
- Google Ads conversion tracking — how many people who clicked an ad actually purchased or submitted a form.
- Meta (Facebook) Pixel — tracking for Facebook and Instagram ads.
- LinkedIn Insight Tag — tracking for B2B ad campaigns.
- Custom HTML/JavaScript — anything else you need on the site without touching the code, like a chat widget or heatmap tool.
How to install Google Tag Manager on your website
1. Create an account and container
At tagmanager.google.com, create an account and a container for your website. Google will generate two code snippets for you.
2. Add the code to your site
The first snippet goes in the <head>, as close to the top as possible. The second goes right after the opening <body> tag. If you don't have direct access to your site's code (e.g. on WordPress), a plugin can usually handle this instead.
3. Your first tag: GA4 configuration
Once the container is live, create your first tag — a "Google Analytics: GA4 Configuration" tag — add your measurement ID, and set the trigger to "All Pages" so it fires on every page.
4. Publishing changes
Changes in GTM don't go live immediately. Test them first in Preview mode, then click "Submit" to publish a new container version to your live site.
Triggers and variables: the foundation every tag relies on
Once you've got the basic install down, you'll run into two concepts GTM can't function without. A trigger decides when a tag should fire — on page load, a button click, or a form submission, for example. A variable is a value a tag or trigger works with — the current page URL, the text of a clicked button, or the ID of the submitted form. Combining triggers and variables lets you define precisely when and based on what a piece of tracking should fire, with no coding required.
A practical example: tracking a contact form submission
The scenario I set up most often is measuring how many people actually submit a contact form. Roughly, it works like this:
- The form needs to either redirect to a thank-you page after submission, or fire a dataLayer event — a signal GTM can pick up.
- In GTM, create a new trigger of type "Form Submission" or "Custom Event," depending on how the form is actually built.
- Create a "Google Analytics: GA4 Event" tag that fires on that trigger and sends the conversion information to Analytics.
- Use Preview mode to confirm the event only fires on an actual submission — not just when the form is displayed.
The result: in Google Analytics and Google Ads, you can see exactly how many form submissions your marketing campaigns actually drove — not just how many people visited the site.
GTM and cookie consent (Consent Mode)
If your site shows a cookie banner (and under GDPR in the EU, it has to), you need to make sure tracking tags don't fire before a visitor gives consent. Google Tag Manager has a built-in tool for this called Consent Mode — tags can be tied to a specific consent category (statistics, marketing) and only fire once that category is accepted. Without proper consent mode setup, a site risks collecting data without valid consent, which is a real GDPR exposure.
The most common setup mistakes
- The container snippet is only added once (usually just in the
<head>), which makes tracking unreliable for visitors with slow connections or blocked JavaScript. - Tags get published without testing in Preview mode first, so a tracking error only surfaces weeks later — after the data's already skewed.
- Old, unused tags from long-dead ad campaigns are left sitting in the container, quietly slowing the site down.
- A conversion tag fires every time a form is displayed rather than actually submitted — artificially inflating numbers and skewing campaign evaluation.
- Tracking tags fire regardless of cookie consent, which is a legal problem, not just a technical one.
When it's worth hiring a professional
A basic GTM install is manageable with a bit of patience. But once you want to track specific actions — button clicks, form submissions, add-to-cart events — you're into custom triggers and variables, where mistakes are easy to make. If you'd rather be sure your analytics data is actually accurate, get in touch about web maintenance — setting up GTM and conversion tracking is a routine part of what I do.