Combine the use of Google Tag Manager with automated cookie blocking by Cookiebot to get the best of both worlds. Implementation is quick and easy and allows you to:
- Control tags and cookies based on the user's consent, using triggers and Consent Mode in Google Tag Manager AND
- Let Cookiebot automatically control all other cookies not set by Google Tag Manager, based on the consent given, typically cookies set by third party scripts that are embedded directly in your website.
To achieve this, make sure that the Cookiebot script is not executed by Google Tag Manager. So either remove the Cookiebot CMP tag, pause it, or remove the "All Pages" trigger assigned to it.
- Ensure that the Google Tag Manager script is first to load on your website.
- Mark up your Google Tag Manager script tag with:
This will ensure that the Google Tag manager script won't unintentionally get blocked by the auto blocking feature.
- Insert the Cookiebot script with automatic cookie blocking immediately after Google Tag Manager script.
Here's an example of how this could look:
If you have renamed the dataLayer, you need to add the
data-layer-name attribute to the Cookiebot script tag, with the new dataLayer name as its value.
For the tags which support Consent Mode: Google Ads (Google Ads Conversion Tracking and Remarketing), Floodlight, Google Analytics and Conversion Linker, we recommend using Google Consent Mode, which can be activated by inserting the following snippet right before the Google Tag Manager script in your header:
Furthermore, if you have renamed the dataLayer, ensure that you replace
window.dataLayer with the actual name of the dataLayer.
= window.gtmDataLayer || ;
For all other cookie-setting tags in Google Tag Manager, implement a trigger for each of the three categories.
If you're modifying a previous Cookiebot implementation:
Change the event name for each tag from
Or if you're creating new triggers:
- From the menu on the left, select Triggers
- Create a new trigger by clicking New and choose Custom Event
- Under Event name, for each of the categories, enter the corresponding value:
Preferences : cookie_consent_preferences Statistics : cookie_consent_statistics Marketing : cookie_consent_marketing
- Make sure All custom events is checked under This trigger fires on
- Click Save to create the trigger.
Assign these triggers to the tags you wish to control based on the user's consent. For example, assign the
cookie_consent_marketing trigger to your Facebook Pixel Code tag like here:
If you adjusted existing triggers, you don't need to assign them again to the tags they were assigned to.
You may also implement the use of Google Tag Manager with manual blocking and implementation of prior consent for any remaining elements outside your tag manager. Use the script for manual cookie blocking and follow our guide here for setting up Google Tag Manager implementation