Cookiebot implementation with Google Tag Manager (GTM)
Cookiebot implementation works great in combination with Google Tag Manager .
You can combine Cookiebot’s automated cookie blocking with Google Tag Manager to get the best of both worlds.
Follow below steps for your Cookiebot implementation:
- Implement the Cookiebot cookie banner
- Implement prior-consent
- Show the cookie statement on a specific page on your website
Make sure you already have created a Google Tag Manager account, created a website container and implemented the GTM code on your website. More information: https://support.google.com/tagmanager/answer/6103696
1. Implementing the Cookiebot cookie banner with GTM
In your GTM container, click “Templates” > “Tag Templates” > “Search Gallery” and select “Cookiebot CMP” from the list of community tag templates. Click “Add to workspace” and confirm by clicking “Add”.
Create a new tag by clicking “New tag” then click “Tag Configuration” and search for “Cookiebot CMP” from the list of standard tag types.
In the “Cookiebot ID” field, copy in the ID from the ‘Your Scripts’ tab under your account on cookiebot.com.
Choose “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 tag configuration should look like (except for the value of the Cookiebot ID):
Make sure that you have registered and saved the domain name(s) of your website(s) in Cookiebot.
To make sure cookies are only loaded when a user gives consent (so-called prior-consent) we will need to create some triggers.
2. Implement prior-consent
To honor the visitor’s consent, you need to define the logic that controls the behavior of cookie-setting tags on your website.
In your GTM container, click “Templates” > “Variable Templates” > “Search Gallery” and select “Cookiebot Consent State” from the list of community variable templates. Click “Add to workspace” and confirm by clicking “Add”.
Now, add a variable and name it “Cookie Consent” by creating a new Variable and selecting “Cookie Consent State” from the list of standard variables. No configuration is available or needed.
Then, create the following triggers, to be used in your GTM configuration:
- Event Name: cookie_consent_preferences, Event Type: Custom Event, Fires On: Some Custom Events, Filter: Cookie Consent – contains – preferences
- Event Name: cookie_consent_statistics, Event Type: Custom Event, Fires On: Some Custom Events, Filter: Cookie Consent – contains – statistics
- Event Name: cookie_consent_marketing, Event Type: Custom Event, Fires On: Some Custom Events, Filter: Cookie Consent – contains – marketing
Tags that set cookies within one of these three categories (see the scan report from Cookiebot if you are in doubt) must only be triggered when the user has consented to the relevant category/categories.
To achieve this, replace the existing Firing Trigger on each cookie-setting tag with the relevant cookie-trigger, e.g. “Cookie Consent Statistics” for Analytics.
If a tag requires more than one trigger, e.g. multiple cookie-categories, then create a new trigger of type Trigger Group and add all the relevant cookie-triggers and any other trigger and set “This trigger fires on” to “All conditions“. Replace the tag’s existing trigger with this Trigger Group.
3. Implementing the cookie statement
To make available an option for the user to change or withdraw consent, implement Cookiebot’s ‘Cookie Declaration‘ on a page of your own choice by embedding the following script tag directly into the source of the page and position within the page where you want the cookie declaration to be displayed (replace 00000000-0000-0000-0000-000000000000 with your own Cookiebot ID):
Make sure to link to the page that embeds the declaration from all pages on your website, e.g. in the website template footer.