Cookiebot Google Tag Manager implementation and configuration

Learn how you can use Cookiebot with Google Tag Manager (GTM). The Cookiebot solution works great with a GTM implementation. Find out below how to implement and configure Cookiebot with Google Tag Manager.

Combine the use of Google Tag Manager with automatic cookie blocking by Cookiebot to get the best of both worlds. If you want to use automatic cookie blocking together with GTM please check out this knowledgebase article: Google Tag Manager and automatic cookie blocking

In the next steps we will show you how to:

  1. Implement the cookie consent banner with Google Tag Manager
  2. Control cookie-setting tags
  3. Show the cookie declaration on a specific page on your website

We are assuming you have created a Google Tag Manager account, created a website container and implemented the Google Tag Manager code on your website. More information on implementing Tag manager at the bottom of this page.

1. Implementing Cookiebot with Google Tag Manager

**** If you want to use automatic cookie blocking together with GTM please check out this knowledgebase article: Google Tag Manager and automatic cookie blocking

In the Google Tag Manager container click on “Templates” in the left menu. Then in the “Tag Templates” panel click the button “Search Gallery”:

Cookiebot with Google Tag Manager

Type “Cookiebot” in the searchbox and select the GTM template “Cookiebot CMP” from the results:

Cookiebot Google Tag Manager - tag template

Then click the button “Add to workspace”. You will see a warning dialog where you will be asked to allow Cookiebot to add scripts in your website. Click “Add”.

Now create a new tag by clicking on Tags in the left menu and the click on the button “New”. Click on “Tag configuration”, and look for the “Cookiebot CMP” under “Custom” in the “Choose tag type” screen. Select this tag:

Fill in the field “Your Cookiebot Domain Group ID” with your personal Cookiebot code. (Which you will find in the Cookiebot manager , tab ‘Your scripts‘).

Under the collapsible configuration group ‘Default Consent State’ you can adjust which categories of cookies should be granted or denied before the end user submits consent. As most data protection legislations like GDPR require so-called ‘prior consent’, the default setting is ‘Denied’ for all categories. The category ‘necessary’ (mapped to consent type security_storage) is by default set to ‘Allow’ and is not configurable, as it does not require consent.

Cookiebot Google Tag Manager - default consent state

Google Tag Manager by default supports 7 different consent types that are automatically mapped by Cookiebot to the 4 categories used in Cookiebot CMP:

Google Tag Manager Consent TypeMapped Cookiebot TypeDescription
ad_user_datamarketingControls whether personal data is sent to a Google core platform service.
ad_personalizationmarketingControls whether data can be used for ads personalization (e.g. remarketing).
ad_storagemarketingEnables storage (such as cookies) related to advertising
analytics_storagestatisticsEnables storage (such as cookies) related to analytics e.g. visit duration
functionality_storagepreferencesEnables storage that supports the functionality of the website or app e.g. language settings
personalization_storagepreferencesEnables storage related to personalization e.g. video recommendations
security_storagenecessaryEnables storage related to security such as authentication functionality, fraud prevention, and other user protection. Users will be informed about the specific storage purposes in the cookie declaration, but this type does not require consent from the end user.

Choose “Consent initialization – All pages” as trigger and apply a name to your tag at the top of the configuration page, e.g. “Cookiebot”. Click “Save” to create the tag.
 
This is what your tags should look like:

Make sure that you have registered and saved the domain name(s) of your website(s) in the Cookiebot manager.  

2. Controlling cookies with Cookiebot in Google Tag Manager

Google Tag Manager includes several features that work together with Cookiebot to help you manage how tags behave in response to the end user’s consent choices.

Tags with built-in consent checks (such as Google Ads, Analytics, Floodlight and Conversion Linker) include logic that automatically changes the tag’s execution behavior based on the user’s consent state. No consent configuration is needed for this type of tags.
Google refers to this as Advanced Consent Mode.

If a tag doesn’t support built-in consent checks, you can add Additional Consent Checks for the tag as described below. If a user does not give consent to the specific consent types you’ve selected for the tag, the tag will not run. This tag will only be executed once permission has been given.
Google refers to this as Basic Consent Mode.

2.1. Setting up Additional Consent Checks

1. In your GTM container, create the following trigger, to be used in your GTM configuration:

Event Name: cookie_consent_update,
Event Type: Custom Event,
Fires On: All Custom Events

You trigger should look similar to this:

2. Tags that do not support built-in consent checks and set cookies should specify the types of cookies using the Additional Consent setting under Tag Editor > Advanced Settings with the categories that the tag requires (see the scan report from Cookiebot if you are in doubt).

In this example the tag requires consent for ad_storage:

3. To achieve this, update any cookie-setting tags to replace the existing trigger (e.g. “All Pages”) with the new consent update trigger, e.g. for your Facebook Pixel Code tag. This will fire your tag when the user has opted in on the required consent type.

If multiple conditions are necessary you can use a trigger group to join those conditions into one trigger. (https://support.google.com/tagmanager/answer/9164222?hl=en)

4. For a complete view of the consent settings across all the tags in your container, you can enable the Consent Overview from your container settings.

If you implement Cookiebot using GTM you can also use Cookiebot to block tags which are not loaded by GTM. For example script tags that are inserted directly in your website template. Just mark up such tags for ‘prior consent’ as described in this article: https://www.cookieinfo.net/en/knowledge-base/manually-enable-prior-consent/

This script is inserted in the HTML of the page where your cookie declaration has to be visible. If you don’t have such a page create a new page for it. Replace the green code below for the code from the cookie manager. (Which you will find in the Cookiebot manager , tab ‘Your scripts‘):

<html>
<head>
...
</head>
<body>
<h1>Cookie verklaring</h1>
<script id="CookiePolicy" src="https://consent.cookiebot.com/00000000-0000-0000-0000-000000000000/cd.js" type="text/javascript" async></script>
</body>
</html>

You can let your web developer implement these scripts. Just send him/her the scripts and the information on this page.

Implementing Google Tag Manager: : https://support.google.com/tagmanager/answer/6103696

Want to get better data out of your Google Tag Manager cookie banner setup? Have a look at our custom cookie banners.

Want to learn more about Google Tag Manager and GDPR compliance, read our blog article here.

14 day free trial Cookiebot

Cookie scanner, cookie banner, cookie declaration and cookie consent in one solution.

  • Use cookies on your website compliant with GDPR, ePrivacy and cookie legislation
  • Cookie management completely automated
  • Cookie banner based on your corporate identity
  • Automatic composed cookie declaration, always up to date

The Cookiebot solution runs on 2 million websites, manages 6.3 billion monthly User Consents and supports 47+ languages.