Close this search box.

How to Install Consent Mode V2 (with Google Tag Manager and Cookiebot)

Want to learn how to install consent mode v2?

Google recently announced that the consent mode version 2 is becoming mandatory to build in your consent management platform if you want to utilize the advertising features of the available Google products.

In this tutorial, you’ll learn how to install consent mode v2 using Cookiebot and Google Tag Manager. This step-by-step guide covers everything from setting up your consent banners to configuring consent-based triggers for your GTM tags.

GTM For Beginners

Sign up to the FREE GTM for Beginners Course...

Here is an overview of what we’ll cover:

Let’s dive in!

Cookiebot Setup

Let’s start by going to the Cookiebot website.

Cookiebot website

It is one of the many tools you can choose from if you want a consent management platform with the built-in features of the Google Consent Mode.

They offer a generous 14-day free trial and continue with a free plan for a single domain website and up to 50 subpages.

Go to PricingStart your free trial to get started.

Starting a Cookiebot free trial

Once you have signed up, go to the Domains section and input the domain name of your website where you want to enable cookie consent.

Adding the website domain name to the domain list

Next, go to the Configuration section to design the consent banner you want to show on your website.

Going to the configuration section

Here is our cookie consent banner.

Cookie consent banner creation in Cookiebot

Then, note that I added the cookies and trackers running on our website in the Cookies & Reports section.

Adding cookies and trackers in the cookies & reports section

I added them manually because my website is under a login. It is not possible to get my website scanned. For most websites, however, you would scan your website, and it will pick up the cookies and trackers automatically.

💡 Top Tip: Check out our How to Create a GTM Cookie tutorial to learn how to collect and store more user data.

Finally, on our website, we have Google Tag Manager installed. Currently, we have four tags running that we want to put under the Consent Management Platform and consent mode.

Initial tags in the GTM account

We have the conversion linker, Google Analytics 4 Google tag, Google Ads remarketing, and Meta Pixel tags.

How to Install Consent Mode V2 in Google Tag Manager

Here is our demo shop where we will implement our consent banners.

MeasureSchool demo shop

We currently don’t have any cookie consent or consent banner set up. Let’s change that by installing Cookiebot.

The cool thing about Cookiebot is that they have their custom tag template in the Community Template Gallery that we can install easily.

In our Tags section, click New.

Creating a new tag

Select the Tag Configuration and open the Community Template Gallery.

Opening the Community Template Gallery

Search for Cookiebot and select the Cookiebot CMP tag template.

Selecting the Cookiebot tag template

Click Add to Workspace. Confirm by clicking Add.

Adding the Cookiebot tag template to the workspace

Next, we need the Cookiebot ID. We can get this value from Cookiebot in the Implementation section. Copy the Cookiebot ID.

Copying the Cookiebot ID

Paste the Cookiebot ID in the allocated spot and click Enable Google Consent Mode.

Pasting the Cookiebot ID and enabling Google consent mode

Enabling this option will connect our consent banner with the right calls to Google Tag Manager, the data layer, and the Gtag that uses the Consent Management API. So, we have all the right calls automatically here.

All you need to do once you have the Google consent mode enabled is to choose our default consent state. So, what should our state be once the consent popup loads before any tags fire?

You can decide on different consent states per region or apply a default state globally.

Click Add region. Next, leave the region empty and keep all default states at Denied. Finally, click Add to save this default consent state.

Adding a globally applied default consent state

Let’s add a name to the tag and add a trigger by clicking Triggering.

Naming the tag and adding a trigger

We’ll use the Consent Initialization – All Pages trigger because we want this tag to fire before any other tags.

Selecting the consent initialization trigger

Save the tag and enter the Preview mode.

Entering the GTM preview mode

Put in your website’s domain and connect the Tag Assistant to your site. Your website will open in another tab.

Here we go! We get our consent popup where we can choose the different cookie categories we can allow or deny. Click Allow All.

Allowing all cookies

Let’s take a look at the Tag Assistant at this stage. We can see a lot of different calls now.

We have an initial Consent event with the consent calls made to the Gtag through the consent mode API.

Initial consent event API calls

Here, we can see the different categories like ad_personalization, analytics_storage, etc. There are also new categories from the consent mode v2, like ad_storage and ad_user_data. By default, they are all denied.

Once the user has made a decision, another Consent event will fire. This event will update all the consent calls based on the user’s choice. In this event, no tags are firing.

Updated consent calls based on the user’s choice

All our other tags fire at an earlier event, the Container Loaded event.

Container Loaded event where all other tags fire

The Gtag, Google Ads, Conversion Linker, and Meta Pixel tags fire at this stage, which shows our tags are not yet connected to the consent management platform or to any of the consent choices the user has made.

We need to update the triggers of our tags so that they fire once the user has made their consent selection. Since we use the consent mode, we can connect GTM to these consent calls with the consent overview.

Connecting GTM Tags to the Consent Management Platform

Inside Google Tag Manager, go to AdminContainer Settings.

Opening the GTM container settings

Under additional settings, enable Consent Overview.

Enabling consent overview in the GTM container settings

Now, we can utilize specific triggers, kind of like new triggers, and add them to the tags.

In the Tags section, click the new button beside New, which opens the consent overview.

Opening the GTM consent overview

Here, you will see which tags have the new configuration of the consent overview applied to them, and we don’t have any of these applied yet.

GTM consent overview

All our tags don’t have the secondary trigger that determines whether it can fire. There is also the built-in consent field that alters the functionality of the tags.

Looking at the GA4 Gtag, for example, if you have built-in consent and the user denies the ad_storage or analytics_storage, it will send cookie-less pings as part of the advanced consent mode. More on this later.

How to Block Tags If There’s No Consent Given

What if the user revokes consent? So, we need to require additional consent to our tags to block tags from firing.

For example, open the GA4 Gtag and scroll to the consent settings. All tags have these additional settings now, where you can choose which additional consent is required for the tag to fire.

Select Require Additional Consent for Tag to Fire and add the categories for which you wish to act as a secondary trigger for the tag to fire.

Requiring additional consent to the Gtag

Another option for requiring additional consent is to tick the checkbox beside the tags you want to put under a specific scope and select the shield icon.

Configuring additional consent for multiple tags

Follow the steps earlier for requiring additional consent. For the Meta Pixel tag, let’s include ad_storage. Save our configuration.

Requiring ad_storage as additional consent for the Meta Pixel tag

Repeat either method to add ad_storage for the conversion linker and Google Ads remarketing tag as additional consent.

Requiring ad_storage as additional consent for the conversion linker and remarketing tags