Cookie consent only works when your consent tool actually blocks scripts until a visitor chooses, not when it just shows a banner.

With Cookiebot and Google Tag Manager, that comes down to three pieces working together:

  • The Cookiebot CMP template on the Consent Initialization trigger, with Consent Mode v2 switched on.
  • A cookie_consent_update trigger on every tag that needs consent, in place of All Pages.
  • data-cookieconsent markup on scripts and iframes that live outside Tag Manager.

Here for the Cookiebot setup? Jump to the Cookiebot and Google Tag Manager walkthrough, then come back for testing.

The rest of this guide covers the rules, the architecture, platform choice and the mistakes that sink most setups.

What Cookie Consent Actually Requires

Under the GDPR and the ePrivacy Directive, non-essential cookies need informed, freely given and specific consent first.

That rules out pre-checked boxes, “by continuing to browse you agree” notices and cookie walls that hide content.

In practice, valid consent needs four things from your setup:

  1. Prior blocking: non-essential scripts don’t run until the visitor gives consent.
  2. Granular choice: visitors can accept or reject categories like analytics and marketing separately.
  3. Easy withdrawal: taking consent back is as easy as giving it.
  4. Records: you can show who consented, when and to what.

The ICO’s guidance on cookies is clear that consent must be active and informed.

For the wider picture of how tracking fits into marketing, see what analytics in digital marketing actually means.

The Technical Architecture

Three layers work together here: the consent management platform (CMP), your tag manager and your tracking scripts.

Here’s how a typical consent flow runs from the first page load to the next visit:

  1. The CMP loads and shows the consent banner.
  2. The visitor accepts all, rejects all or picks specific categories.
  3. The CMP stores the choice in a cookie and pushes the consent state to the dataLayer.
  4. Google Tag Manager reads that state and fires or holds each tag.
  5. On later visits, the CMP reads the stored choice and applies it without a banner.

Step 4 is where most setups fail, because a banner means nothing if tags fire before the choice.

If the data layer is new to you, read our data layer explainer before you wire anything up.

How Consent Mode v2 Fits In

Google’s Consent Mode passes the visitor’s choice to Google tags through consent parameters.

Version 2 added ad_user_data and ad_personalization to the original ad_storage and analytics_storage parameters.

It runs in two modes, and the difference matters for privacy and for your data:

  • Basic mode: Google tags stay blocked until the visitor interacts with the banner, so nothing reaches Google before that.
  • Advanced mode: Google tags load with denied defaults and send cookieless pings, which Google uses for modeling.

Consent Management Platforms Compared

Picking a CMP is one of your first decisions. Here’s what the main vendors publish about their own plans:

PlatformFree optionPaid plansNotes
CookiebotFree plan for one domain with up to 50 subpagesPriced by subpages per domain, 14-day free trialOfficial Cookiebot CMP template for Google Tag Manager
CookieYesFree plan with 100 pages per scan and 5,000 pageviews a monthFrom $10 a month per domainPriced by pageviews and scan size
OneTrustNo free plan on its pricing pageQuote based on average daily visitorsCovers websites, mobile apps and connected TV
Osano30-day free trialPricing on requestMentions a Google Tag Manager integration and IAB TCF strings

For most small and medium sites, Cookiebot or CookieYes is the practical choice. Both list IAB TCF v2.4 on their pricing pages.

The IAB Transparency and Consent Framework matters mainly if you run programmatic advertising on your site.

Step 1: Audit Your Cookies and Scripts

Before you install anything, you need a list of what you’re managing. Start with a clean private window.

Clear all cookies, load your homepage and open the Application tab in your browser’s DevTools to see what’s set.

Sort every cookie you find into one of these categories:

  • Strictly necessary: session IDs, shopping carts and security tokens. These don’t need consent.
  • Analytics: Google Analytics (_ga), Hotjar, Clarity and similar tools. These need consent.
  • Marketing: Meta Pixel (_fbp), Google Ads (_gcl_au) and LinkedIn Insight. These need consent.
  • Functional: language preferences and chat widgets. Whether they need consent depends on the setup.

Check embeds too, since YouTube videos, maps and social buttons often set cookies of their own.

CMP scanners help, but verify by hand, because scans can miss scripts that load late or inside iframes.

Step 2: Choose and Install a CMP

This guide uses Cookiebot as the example. Its basic install is one script tag at the very top of your <head>:

<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js"
  data-cbid="YOUR-DOMAIN-GROUP-ID"
  data-blockingmode="auto" type="text/javascript"></script>

The data-blockingmode="auto" attribute tells Cookiebot to block known tracking scripts until the visitor consents.

Automatic blocking is quick, but it won’t catch every custom script, so most teams pair it with Tag Manager.

If your site already runs Google Tag Manager, you can skip this tag and load Cookiebot from Tag Manager instead.

Step 3: Set a Default Consent State

Google tags need a default consent state before anything else runs. Without it, they behave as if consent was granted.

A CMP template in Tag Manager sets this for you. With a hand-coded setup, add a default command above the GTM snippet:

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'analytics_storage': 'denied',
    'wait_for_update': 500
  });
</script>

The wait_for_update value gives a slow-loading CMP 500 milliseconds to send its update before tags fire.

When the visitor accepts analytics, the CMP sends the update for you, so you never write this part by hand:

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

Google’s consent mode developer guide covers regional defaults and the update command in full.

Cookiebot in Google Tag Manager with Consent Mode v2: Step by Step

This walkthrough follows Cookiebot’s Google Tag Manager deployment guide and Google’s consent mode documentation.

You’ll need a GTM container already on your site, plus your domain added and saved in your Cookiebot account.

Copy your Domain Group ID from Cookiebot first. It looks like 00000000-0000-0000-0000-000000000000 with letters and digits.

1. Turn On the Consent Overview

In GTM, open Admin, then Container Settings, and tick Enable consent overview under Additional Settings.

A shield icon then appears in the Tags list, showing each tag’s consent setup in one view.

2. Add the Cookiebot CMP Template

  1. Open Templates and click Search Gallery in the Tag Templates section.
  2. Search for “Cookiebot” and select Cookiebot CMP.
  3. Click Add to workspace, then confirm with Add.

3. Create the Cookiebot Tag

  1. Click New, then Tag Configuration, and pick Cookiebot CMP.
  2. Paste your Domain Group ID into the Cookiebot ID field.
  3. Set the trigger to Consent Initialization – All Pages, name the tag “Cookiebot” and save.

Consent Mode is on by default in this template, under the Enable Google Consent Mode checkbox. Leave it ticked.

The template applies a default state of “denied” until the visitor submits a choice.

You can add regions with ISO codes like DE, FR or US-CA. Cookiebot recommends always keeping one global region.

Cookiebot maps Google’s seven consent types onto its own four categories like this:

GTM consent typeCookiebot category
ad_storage, ad_user_data, ad_personalizationMarketing
analytics_storageStatistics
functionality_storage, personalization_storagePreferences
security_storageNecessary, always allowed

4. Create the cookie_consent_update Trigger

This trigger is the piece most people search for, and it’s quick to set up:

  1. Open Triggers, click New and choose Custom Event.
  2. Enter cookie_consent_update as the event name.
  3. Leave it on All Custom Events and save.

Here’s why it matters. Updating consent doesn’t make Tag Manager re-check tags that already ran on All Pages.

So a consent-gated tag on All Pages misses the page where the visitor clicks accept and waits for the next one.

With cookie_consent_update as the trigger, the tag fires as soon as the choice is known, from the banner or an earlier visit.

5. Add Consent Checks to Your Tags

Google Ads, Analytics, Floodlight and Conversion Linker tags have built-in consent checks. Google calls this advanced consent mode.

Those tags load regardless of consent and adjust what they send, so they need no extra setup.

Other tracking tags, like the Meta Pixel or LinkedIn Insight, have no built-in checks and need two changes:

  1. Open the tag, go to Advanced Settings, then Consent Settings.
  2. Choose Require additional consent for tag to fire and add the storage types it needs, such as ad_storage.
  3. Replace its All Pages trigger with your cookie_consent_update trigger.

Want nothing sent to Google before consent? Add additional consent checks to Google tags too, which gives you basic mode.

With many tags, use the shield icon in the Consent Overview to set consent requirements on several at once.

Cookiebot also pushes cookie_consent_preferences, cookie_consent_statistics and cookie_consent_marketing events you can use as triggers.

There’s also a Cookiebot Consent State variable in the gallery. With full consent it returns |preferences|statistics|marketing|.

6. Block Scripts Outside GTM with data-cookieconsent

Scripts pasted straight into your theme don’t pass through Tag Manager, so Cookiebot needs markup to hold them.

For an inline or external script, change its type to text/plain and add a data-cookieconsent category:

<script type="text/plain" data-cookieconsent="statistics">
  // your analytics code here
</script>

Cookiebot switches the type back and runs the script once the visitor accepts that category.

Iframes and images have no type attribute, so you rename src to data-cookieblock-src instead:

<iframe data-cookieconsent="marketing"
  data-cookieblock-src="https://www.youtube.com/embed/VIDEO_ID"></iframe>

Valid values are preferences, statistics, marketing and ignore. You can combine categories, like "statistics, marketing".

There’s no “necessary” value. Necessary scripts simply stay unmarked, as Cookiebot’s manual blocking guide explains.

7. When to Use data-cookieconsent=”ignore”

The ignore value matters when you combine automatic blocking with Tag Manager. It stops auto-blocking from touching a script.

For that combination, Cookiebot’s own instructions boil down to four rules:

  • Don’t load Cookiebot through GTM. Remove or pause the Cookiebot CMP tag, or remove its trigger.
  • Place the Consent Mode default script first, the GTM snippet second and the Cookiebot script third.
  • Add data-cookieconsent="ignore" to the Consent Mode and GTM script tags.
  • Keep data-blockingmode="auto" on the Cookiebot script so it handles everything else.
<script data-cookieconsent="ignore">
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    'ad_personalization': 'denied', 'ad_storage': 'denied',
    'ad_user_data': 'denied', 'analytics_storage': 'denied',
    'functionality_storage': 'denied', 'personalization_storage': 'denied',
    'security_storage': 'granted', 'wait_for_update': 500
  });
</script>
<!-- Google Tag Manager snippet, also with data-cookieconsent="ignore" -->
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js"
  data-cbid="YOUR-DOMAIN-GROUP-ID" data-blockingmode="auto"
  type="text/javascript"></script>

Use ignore sparingly. Any element with it can set tracking cookies without consent.

Cookiebot also warns that adding it to scripts that wouldn’t be blocked can confuse auto-blocking and break the page.

8. Let Visitors Change Their Minds

Withdrawal has to be easy, so publish Cookiebot’s cookie declaration on a page and link it from your footer:

<script id="CookieDeclaration"
  src="https://consent.cookiebot.com/YOUR-DOMAIN-GROUP-ID/cd.js"
  type="text/javascript"></script>

9. Check It in GTM Preview

Open Preview mode and load your site. The Cookiebot tag should fire on the Consent Initialization event.

Select that event and open the Consent tab. Every type except security_storage should read denied.

Now accept statistics only. A cookie_consent_update event should appear with analytics_storage granted.

Your marketing tags should stay in the Tags Not Fired list until you accept the marketing category as well.

Step 4: Test Consent Behavior

Whatever CMP you use, test every path, because a banner can look right while scripts fire anyway.

  1. Clear all cookies and open your site in a private window.
  2. Ignore the banner. No analytics or marketing cookies should exist. In basic mode, the Network tab should show no tracking requests.
  3. Reject all. You should see the same result as before.
  4. Accept only analytics. Analytics cookies like _ga should appear, and marketing cookies shouldn’t.
  5. Accept all. Every expected cookie should now be set.
  6. Withdraw consent through your footer link and confirm that tracking stops.

Repeat these checks after big site changes, since new plugins and embeds often bring new cookies with them.

Common Implementation Mistakes

The same handful of problems shows up in setup after setup. Watch for these before you go live:

  • Scripts hardcoded in the theme. A GA4 snippet pasted into header.php fires on load unless you mark it up or route it through GTM.
  • No default denied state. Without it, Google tags assume consent and fire while the CMP is still loading.
  • Consent-gated tags on All Pages. They miss the page where the visitor accepts. Use cookie_consent_update instead.
  • Using ignore as a quick fix. It removes blocking for that script, so tracking can run without consent.
  • Testing only the accept path. Rejection is what regulators check, so test it first.
  • Forgetting embeds. Videos, maps and social widgets need blocking too, or a privacy-friendly embed like youtube-nocookie.com.

When You Don’t Need a Cookie Banner at All

If your site sets no non-essential cookies, you don’t need a consent banner for them in the first place.

Plausible, Fathom and Umami measure traffic without cookies, as our roundup of cookie-free Google Analytics alternatives shows.

That route brings practical benefits beyond compliance:

  • No banner friction: visitors see your content straight away.
  • Fuller data: you count visitors who would have rejected cookies, not only those who accepted.
  • Lighter pages: no CMP script and fewer requests on every load.
  • Simpler setup: no consent states and no conditional tags to maintain.

It works best for analytics. Paid ads on Meta or Google still rely on cookies, so you’ll still need consent there.

To weigh that trade-off, it helps to know how attribution models like last-click work.

Key Takeaways

Proper cookie consent management comes down to a few rules you can check in an afternoon:

  • Get consent before non-essential cookies are set, not after.
  • Make sure your CMP blocks scripts, and connect it to GTM with Consent Mode v2.
  • Fire consent-gated tags on cookie_consent_update, not on All Pages.
  • Mark scripts outside GTM with data-cookieconsent, and keep ignore for the few that need it.
  • Test the rejection path first, because that’s what regulators look at.
  • Ask whether you need tracking cookies at all. Cookieless analytics tools remove the consent problem for analytics.

Consent setups drift as plugins and tags change, so schedule a quick audit every quarter and after every redesign.