SiteTidy
HomeGuidesTracking Events with Google Tag Manager (Part 4): Consent Mode, Privacy and Data Boundaries
Analytics

Tracking Events with Google Tag Manager (Part 4): Consent Mode, Privacy and Data Boundaries

Implement consent-aware analytics with Google Tag Manager: consent defaults and updates, basic vs advanced Consent Mode, tag controls, privacy boundaries, testing and failure modes.

Published on August 15, 2026Updated August 31, 2026
Tracking Events with Google Tag Manager (Part 4): Consent Mode, Privacy and Data Boundaries

Analytics implementation used to be treated as a plumbing problem: put the tag on the page, fire events, and check whether numbers arrive.

Consent changes that model.

A modern measurement system has to answer a more important question before it asks which event should fire:

What is this visitor currently allowing us to collect, store and use?

Google Tag Manager can help enforce that decision, but it does not make the decision for you. Google Consent Mode is not a cookie banner, a legal opinion or a replacement for a Consent Management Platform (CMP). It is a mechanism for communicating consent state to Google tags and controlling tag behaviour.

That distinction matters. A beautifully configured GTM container cannot rescue a consent banner that records the wrong choice, a third-party script that loads outside the consent system, or an event payload that contains data you should never have collected in the first place.

This part of the series is about designing the whole chain correctly.

Before touching a trigger, document the categories your organisation actually uses.

A typical implementation might distinguish:

  • strictly necessary/security functionality;
  • analytics or measurement;
  • advertising storage;
  • advertising user data;
  • advertising personalisation;
  • other optional third-party functionality.

The exact legal categories and lawful basis depend on where you operate, what you collect and how you use it. GTM is an implementation tool, not the authority that decides those questions.

For Google’s tag platform, the important Consent Mode states include:

Consent type What it controls
analytics_storage Storage associated with analytics measurement
ad_storage Storage associated with advertising
ad_user_data Sending user data to Google for advertising purposes
ad_personalization Personalised advertising use
functionality_storage Storage supporting site/app functionality
personalization_storage Storage supporting personalisation
security_storage Storage supporting security and fraud-prevention functions

Do not automatically map every button on a generic cookie banner to every one of these states. Define the mapping deliberately.

Google currently describes basic and advanced Consent Mode.

They are materially different.

In a basic implementation, Google tags are blocked before the user grants the relevant consent. If the visitor does not consent, those blocked tags do not send data to Google.

Conceptually:

Page loads
   ↓
CMP determines current consent
   ↓
Relevant Google tags blocked
   ↓
User grants consent?
   ├─ No  → keep them blocked
   └─ Yes → update consent and allow permitted tags

This is the easier model to reason about when the requirement is simply “do not transmit analytics/advertising measurement until permission exists.”

With advanced Consent Mode, Google tags can load while relevant consent states are denied. Their behaviour changes according to that denied state and cookieless measurements may still be transmitted.

When consent is later granted, the tags can use the fuller measurement behaviour allowed by the new state.

This can provide more information for Google’s modelling systems, but advanced does not mean more compliant. It means a different technical collection model.

Whether that model is appropriate for your organisation and jurisdictions is a privacy/legal decision that must be made deliberately.

Do not choose advanced mode merely because a marketing dashboard promises better modelling.

One of the most damaging consent bugs is a timing bug.

Imagine this order:

1. GTM loads
2. GA4 fires
3. advertising tags fire
4. CMP finally says "analytics denied"

The consent system has technically run, but it ran too late.

The initial state needs to be available before tags that depend on it can act.

In GTM, consent-management templates should normally establish their defaults using the Consent Initialization - All Pages trigger so the consent state is established as early as possible.

For a direct gtag.js implementation, the shape is conceptually:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }

gtag('consent', 'default', {
  analytics_storage: 'denied',
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  wait_for_update: 500
});
</script>

The wait_for_update value can give a CMP a short period to establish the user’s persisted choice before measurement proceeds. It is not an excuse to make the banner slow.

The important principle is the ordering:

default first, measurement second, update when the user’s state changes.

There is a subtle implementation detail here that is easy to miss.

If you are building a GTM consent template, Google recommends the Tag Manager consent APIs such as setDefaultConsentState and updateConsentState rather than trying to implement the template by pushing ordinary gtag('consent', ...) commands.

Why?

Because gtag commands are queued through the data layer. That can create ordering problems where another event is processed before the consent update you expected to apply to it.

Consent is one area where “it eventually reaches the data layer” is not good enough. Timing is part of correctness.

It helps to draw the boundary explicitly.

The CMP should normally handle things such as:

  • presenting the consent interface;
  • recording the visitor’s choices;
  • restoring persisted choices on future visits;
  • allowing choices to be changed or withdrawn;
  • supplying the current state to the tag implementation.

Consent Mode then communicates relevant state to supported Google tags and changes their behaviour.

GTM can additionally gate other tags using consent requirements.

A useful mental model is:

Visitor
   ↓
Consent interface / CMP
   ↓
Canonical consent state
   ↓
GTM consent APIs
   ↓
┌───────────────────────┬───────────────────────┐
│ Google tags           │ Other third-party tags│
│ built-in behaviour    │ explicit GTM controls │
└───────────────────────┴───────────────────────┘

Do not make GTM independently guess what the visitor selected by scraping button text or DOM classes from the banner.

The CMP should expose a reliable state or integration API.

Supported Google tags have built-in consent behaviour. GTM also allows additional consent requirements for tags that need explicit gating.

A common legacy pattern is to duplicate triggers:

GA4 - Page View - Consent Granted
Meta - Page View - Marketing Granted
Ads - Conversion - Ads Granted
Hotjar - Load - Analytics Granted
...

Then every trigger embeds its own consent-variable conditions.

That becomes difficult to audit because privacy policy is spread across dozens of trigger expressions.

Prefer a design where:

  1. the CMP establishes canonical consent state;
  2. GTM’s consent system represents it;
  3. tags declare the consent they require;
  4. business-event triggers remain about the event itself.

The purchase trigger should answer “did a purchase occur?”

The consent layer should answer “is this tag allowed to process that event in this state?”

Those are different concerns.

A visitor can:

  • arrive with no stored choice;
  • grant analytics but deny advertising;
  • later enable advertising;
  • withdraw analytics;
  • revisit tomorrow with a persisted preference;
  • clear their browser storage and become unknown again.

Your implementation needs to behave correctly in all of those states.

Do not model consent as:

dataLayer.push({ event: 'cookie_banner_accepted' });

and assume the job is finished.

A single event tells you something happened. It does not reliably describe the current permission state.

Instead, maintain an explicit state model and issue consent updates when that state changes.

For gtag.js, an update can look like:

gtag('consent', 'update', {
  analytics_storage: 'granted',
  ad_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied'
});

If the visitor later withdraws analytics permission, update it again:

gtag('consent', 'update', {
  analytics_storage: 'denied'
});

Withdrawal is not an edge case. It is part of the normal state machine.

Apply the update before navigating away

Another surprisingly common failure occurs when the visitor clicks Accept and the site immediately redirects or reloads.

If the consent update happens during page unload, the browser may cancel network work associated with that change. Google specifically recommends tracking the update on the page where the choice occurs, before the page transition.

So avoid this:

acceptButton.addEventListener('click', () => {
  saveConsent();
  location.href = '/checkout';
});

when saveConsent() merely schedules asynchronous consent work and navigation immediately destroys the page.

Prefer an integration where the CMP applies the state promptly and navigation is not used as the mechanism for activating consent.

A consent choice should not need a page refresh to become real.

Region-specific defaults need careful ownership

Google’s Consent Mode APIs support region-aware defaults. That can be useful where an organisation intentionally uses different consent defaults in different regulatory regions.

But be careful about turning GTM into a home-grown legal geolocation engine.

Questions such as these need an explicit owner:

  • Which regions receive a banner?
  • What happens if geolocation fails?
  • Which source determines the visitor’s region?
  • Is the decision made at the CDN, CMP, application or GTM layer?
  • What is the conservative fallback?
  • How is the rule tested from each region?

If the CMP already owns regional policy, let it remain the source of truth unless there is a strong reason not to.

This is one of the most important distinctions in analytics engineering:

permission to measure does not mean permission to send arbitrary personal data.

A user granting analytics consent does not turn an email address, password reset token, medical detail, support-message body or full postal address into an acceptable GA4 event parameter.

Avoid collecting sensitive or identifying information in:

  • event names;
  • page URLs;
  • page titles;
  • search terms;
  • form-field values;
  • DOM text variables;
  • data-layer objects;
  • custom dimensions;
  • error messages;
  • referrer URLs.

A particularly nasty leak looks like this:

/account/reset?email=person@example.com&token=abc123

If your analytics implementation automatically records the full page location, you have a data-design problem before GTM even starts evaluating triggers.

Fix the source. Do not rely on a last-minute regex in one analytics tag to hide it.

Be suspicious of DOM scraping

DOM variables are tempting because they let analysts collect values without waiting for an application release.

They also make it easy to collect things nobody intended to put into analytics.

For example:

document.querySelector('.checkout-summary').innerText

might contain product names today and a customer’s address tomorrow after a UI redesign.

Prefer explicit, purpose-built data-layer fields:

dataLayer.push({
  event: 'checkout_completed',
  order: {
    transaction_id: 'ORD-10482',
    value: 89.95,
    currency: 'GBP'
  }
});

That is easier to document, validate and privacy-review.

Third-party tags are part of the threat model

GTM is powerful precisely because it can execute third-party measurement and marketing code without an application deployment.

That convenience deserves governance.

For every third-party tag, know:

  • who receives the data;
  • which event causes transmission;
  • which fields are sent;
  • which consent categories are required;
  • whether cookies or other identifiers are written;
  • whether the vendor loads additional scripts;
  • whether the tag still exists because somebody actively needs it.

A container with 70 tags and no owner list is not a mature analytics system. It is an undocumented integration platform running in every visitor’s browser.

Custom HTML deserves extra scrutiny

Custom HTML tags can execute arbitrary page-side JavaScript. They are sometimes necessary, but they bypass much of the clarity you get from purpose-built templates.

Before adding one, ask:

  1. Is there a supported native tag or vetted template?
  2. Exactly what network requests will this script make?
  3. Does it load more JavaScript dynamically?
  4. What consent does it require?
  5. Can it read form fields or page content?
  6. Who will maintain it when the vendor changes its API?

A tag that “only tracks conversions” can become a much broader data collector after a vendor script update.

Treat third-party JavaScript as code execution, not as a harmless marketing setting.

A dangerous assumption is:

“We enabled Consent Mode, so nothing can leak before consent.”

That is not what Consent Mode guarantees.

It controls supported tag behaviour according to the implementation. It does not magically stop:

  • a hard-coded analytics script in the application;
  • an iframe embedded before consent;
  • a chat widget loaded directly from the page;
  • a marketing pixel inserted by another plugin;
  • server-side events generated independently of the browser’s consent state;
  • personal information accidentally placed in a URL.

You need an inventory of all collection paths.

Audit the public site as well as the container

A tag review is only half the job. Check the pages, scripts, headers and public-facing implementation around it too.

Run a SiteTidy audit →

Part 5 goes much deeper into server-side GTM, but there is one privacy point worth making here.

Moving tag execution from the browser to a server you control can give you more control over what gets forwarded to vendors. It does not mean the data is suddenly outside the consent model.

If the browser sends an event to your tagging server, the system still needs to understand the applicable consent state and respect it downstream.

Server-side tagging is an architectural control point, not a privacy exemption.

Not every browser storage operation is marketing.

Authentication, fraud prevention and abuse protection may rely on storage that serves a security purpose. Google’s model includes security_storage for this reason.

Avoid a simplistic implementation where Reject all disables security controls required to operate the account safely.

Equally, do not label marketing identifiers as “necessary” merely because doing so makes implementation easier.

The categories need to reflect the real purpose of the processing.

Teams often want to measure the consent banner itself:

  • banner shown;
  • accept all clicked;
  • reject all clicked;
  • preferences opened;
  • analytics enabled.

That can be useful for understanding whether the interface works, but be precise about how those events are collected.

If analytics is denied, sending a GA4 event saying consent_rejected may defeat the policy you thought you had implemented, depending on the chosen Consent Mode architecture and legal basis.

If consent-choice telemetry is operationally necessary, design it explicitly rather than casually routing it through the same analytics stack whose permission is being decided.

Another anti-pattern is:

if (window.ga) {
  // must have consent
}

or:

if (document.cookie.includes('_ga=')) {
  // analytics granted
}

Neither is a reliable consent state.

Cookies can be stale. Scripts can load in advanced Consent Mode while storage is denied. Browser extensions and old implementations can create unexpected state.

Ask the consent system for consent.

Build a proper test matrix

Testing only Accept all is almost useless.

At minimum, test:

Scenario What to verify
First visit, no choice Correct defaults exist before dependent tags
Reject all Disallowed tags/storage/transmissions behave as designed
Analytics only Analytics behaviour works; advertising remains denied
Advertising granted Advertising states and tags activate correctly
Existing persisted choice Correct state restored before dependent tags
Grant after initial denial Update occurs immediately without requiring reload
Withdraw consent Future behaviour changes correctly
SPA navigation Consent state survives route changes
Hard navigation Persisted state is restored on next document
CMP unavailable Conservative failure behaviour is known
GTM blocked Site still functions
Third-party script failure Consent UI and core site remain usable

Then test the actual network, not just GTM’s green checkmarks.

Preview mode is necessary, but the Network panel tells the truth

GTM Preview/Tag Assistant is excellent for seeing:

  • which event occurred;
  • consent state at that point;
  • which triggers matched;
  • which tags fired or were blocked;
  • variable values.

But a tag saying Fired is not proof that the intended request reached the vendor, and a tag saying Did not fire does not prove another hard-coded script stayed quiet.

Use browser developer tools as well.

For each consent state:

  1. clear relevant cookies/storage;
  2. reload from a clean state;
  3. inspect requests before interacting with the banner;
  4. make a consent choice;
  5. inspect new requests and cookies;
  6. navigate to another page or SPA route;
  7. verify persistence;
  8. change the preference again;
  9. inspect the network after withdrawal.

This catches bugs that a container-only test misses.

Test the first milliseconds of page load

Consent bugs are often race conditions, so a normal fast local connection can hide them.

Use network throttling and repeat the test.

You want to know what happens when:

  • GTM loads before the CMP library;
  • the CMP loads before GTM;
  • the CMP CDN is slow;
  • persisted consent takes time to read;
  • a SPA mounts immediately;
  • an ecommerce event occurs soon after page load.

The answer should not depend on which vendor’s JavaScript won the race that morning.

A production implementation should have a short document that answers:

CMP:
  Vendor / implementation:
  Owner:

Consent categories:
  Necessary:
  Analytics:
  Advertising:
  Personalisation:

Google mapping:
  analytics_storage:
  ad_storage:
  ad_user_data:
  ad_personalization:

Default state by region:
  ...

Persistence mechanism:
  ...

Tags requiring analytics consent:
  ...

Tags requiring advertising consent:
  ...

Server-side collection paths:
  ...

Last privacy review:
  ...

That document is far more valuable six months later than a container full of tags called Consent Trigger v2 FINAL.

A GTM publish can alter the data transmitted by every page immediately.

So changes to:

  • CMP integration;
  • consent defaults;
  • consent mappings;
  • additional consent requirements;
  • advertising tags;
  • analytics configuration;
  • Custom HTML;
  • server-side forwarding;

should receive appropriate review and testing.

For high-risk changes, retain evidence of the test cases and expected network behaviour.

“It worked in Preview” is not much of an audit trail.

Result: data may be transmitted before the intended state exists.

Fix: establish defaults during consent initialization before dependent tags.

Result: the update may not be fully processed and the original page’s measurement can be incomplete.

Fix: update consent on the current page when the choice changes; do not depend on reload as activation.

Result: inconsistent policy, difficult audits and subtle drift.

Fix: centralise canonical consent state and use GTM consent controls appropriately.

Result: prohibited or unnecessary data can enter analytics systems.

Fix: minimise the event contract independently of consent.

Result: the organisation believes collection is gated when it is not.

Fix: inventory all browser and server collection paths.

Failure: only Accept All is tested

Result: the least privacy-preserving path works perfectly while withdrawal, partial consent and persisted denial are broken.

Fix: maintain a consent-state test matrix.

Production checklist

Before calling a consent-aware GTM implementation complete, verify that:

  • a real CMP or equivalent consent mechanism owns the visitor choice;
  • the organisation has documented what each consent category means;
  • default consent state exists before dependent tags can act;
  • GTM consent templates use the Tag Manager consent APIs correctly;
  • basic vs advanced Consent Mode was chosen deliberately;
  • analytics_storage, ad_storage, ad_user_data and ad_personalization mappings are understood where applicable;
  • consent updates occur immediately when choices change;
  • withdrawal works without requiring a fresh browser session;
  • persisted choices are restored reliably;
  • SPA navigation does not reset or duplicate consent handling;
  • third-party tags have explicit owners and consent requirements;
  • Custom HTML is minimised and reviewed;
  • URLs and event payloads are checked for PII/sensitive data;
  • server-side collection paths respect the same privacy model;
  • partial-consent and rejection scenarios are tested;
  • network requests and cookies are inspected, not merely GTM Preview;
  • failure behaviour is known when the CMP or tag infrastructure is unavailable.

The principle to keep

Consent is not a trigger condition bolted onto analytics after the tracking plan is finished.

It is an input to the measurement architecture.

The strongest implementations have one trustworthy consent state, establish it early, propagate changes immediately, minimise the data regardless of permission, and test what actually leaves the browser.

Do that, and GTM becomes a useful enforcement and orchestration layer rather than a place where privacy logic quietly fragments.

In Part 5, we finish the series by moving beyond individual events into server-side tagging, container governance, observability, release discipline and the practices that keep a measurement system trustworthy after it has been running for years.

Ready to audit your site?

Put this guide into practice immediately using our free tools.

Browse 180+ Free Tools