Google Tag Manager (GTM) is a free tool for adding and managing tracking code on a website, such as Google Analytics 4, Google Ads conversions and other marketing tags, without editing the site each time. You install one GTM container, then set up tags (what to send), triggers (when to send it) and variables (the values). The data layer is a JavaScript object your site uses to pass reliable information to GTM, such as 'form submitted' or a donation amount. In the UK, tags must respect cookie consent.
What is Google Tag Manager?
| Part | What it is | Example |
|---|---|---|
| Tag | Code that sends data to a tool | A GA4 event called generate_lead |
| Trigger | The condition that fires a tag | When the enquiry form's thank-you message appears |
| Variable | A value used by tags and triggers | The form name or donation amount from the data layer |
How do you set up Google Tag Manager?
- Create a GTM account and a web container for your domain.
- Add the two container snippets to every page: one high in the head, one immediately after the opening body tag.
- Add a Google tag for GA4 with your measurement ID, firing on initialisation or all pages.
- Create triggers and tags for the actions that matter: enquiries, calls, purchases or donations.
- Test everything in Preview mode (Tag Assistant), then publish with a clear version name.
- Set up consent: a consent banner and Consent Mode defaults, so tags behave according to each visitor's choice.
For most UK businesses at the SME level, understanding the data layer is more important for knowing what to ask developers to implement than for implementing it yourself. When a business wants to track e-commerce purchases, form submissions with specific field data, or user login status in GA4, the data layer is the mechanism that makes this possible accurately.
What information is typically stored in a data layer
- Page information — page type (home, product, category, checkout), page template, content category
- User information — whether the user is logged in, customer tier, account ID (anonymised, not PII)
- E-commerce data — product name, SKU, price, category, quantity for view, add-to-cart, and purchase events
- Form data — form name, form ID, and selected options (not sensitive field values like passwords or payment details)
- Event triggers — custom events pushed to the data layer by specific user actions (button clicks, video plays, scroll depth milestones)
- Transaction data — order ID, revenue, tax, shipping, coupon codes for purchase tracking
Data layer vs. no data layer tracking
Without a data layer, GTM tracks events using DOM scraping — reading page content, button text, and form field values directly from the HTML. This is fragile: any website redesign that changes a button's text, position, or CSS class can break tracking. A data layer pushes structured, intentional data objects regardless of how the page looks — making tracking significantly more robust and easier to maintain. For e-commerce businesses tracking product performance and purchase data, a proper data layer implementation is essentially mandatory for reliable GA4 e-commerce reporting.
Consent Mode and GTM in the UK
Under UK GDPR and PECR, analytics and advertising cookies generally need consent. A consent management platform records the visitor's choice and passes it to GTM through Consent Mode, which tells Google tags whether they may use cookies. Google requires Consent Mode for its personalised advertising features for UK and EEA traffic, so set it up before you rely on remarketing or audience lists.
When is server-side tagging worth it?
Server-side tagging runs a second GTM container on a server you control, so the browser sends data to your server first and your server forwards it to analytics and ad platforms. It can improve performance, data control and resilience to blocked scripts, but it costs money to host and still has to respect consent. It suits sites with significant ad spend or strict data requirements; most small sites don't need it yet.
Related: Google Analytics 4, UTM tracking, Google Ads conversion tracking and our analytics and reporting service.
Frequently asked questions
Yes — implementing a data layer requires developer access to your website's codebase. The developer needs to add the dataLayer JavaScript object to the relevant pages and push the appropriate data at the right moments (page load, button click, form submission, purchase completion). Once implemented, the data layer can typically be maintained and extended without further developer involvement — a GTM-competent marketer can create new tags that read existing data layer variables without code changes. The initial implementation is a development task; subsequent GTM configuration is a marketing/analytics task.
Google Tag Manager (GTM) is a tag management system that allows you to deploy tracking codes (tags) on your website without modifying site code for every new tag. GTM reads the data layer to receive information from your website, and uses that information to trigger tags and send data to GA4, Google Ads, Meta Pixel, and other platforms. The data layer is the communication channel between your website and GTM; GTM is the system that processes that information and distributes it to the appropriate platforms. Most marketing tracking implementations use both: a data layer on the website and GTM to manage all the tags that consume it.
Google Analytics measures and reports what visitors do. Google Tag Manager is a delivery tool that installs and controls tags, including the Analytics tag. You can use Analytics without GTM, but GTM makes tracking easier to manage.
The container script adds a small amount of code, and every tag inside it adds more. Keep the container tidy: remove unused tags and avoid loading heavy scripts on every page.