Consent Management with Cookiebot and Google Tag Manager Server
Introduction
In this guide, we’ll show you how to manage consent with Cookiebot and Google Tag Manager Server (GTM Server) within the framework of an Advanced Consent Mode V2. The goal is to condition your server-side tags based on the user’s consent given through Cookiebot in the visitor’s browser.
For more context, see our general guide on server-side consent management.

Prerequisites
To follow this guide, you must have the following:
- An advanced Consent Mode V2 implementation in your GTM Web container
- A basic knowledge of Google Tag Manager Web and Server
- An active Cookiebot account with a configured consent banner
- A Google Tag Manager Web container and a Google Tag Manager Server container set up
- Server-side tags already configured in your GTM Server container (for example, a GA4 tag or Meta Conversion API)
Configuring Cookiebot CMP in GTM Web
Adding the Cookiebot CMP tag in GTM Web
To get started, add the Cookiebot CMP tag to your GTM Web container. This allows Cookiebot to manage the user’s consent preferences.
In your GTM Web container, in the Tags section, click “New” to create a new tag.

Then go to the community tag template gallery by clicking on the blue banner below.

Search for “Cookiebot” in the search bar and select the “Cookiebot CMP” template.

Then add the template to your GTM container by clicking on Add to workspace.

Confirm adding the template by clicking on Add.

Once the tag is added in GTM, you need to retrieve the Cookiebot ID from the Cookiebot interface .
To do this, log in to your Cookiebot account, then go to the Implementation section, in the CMP banner tab, scroll down and finally copy the Domain Group ID of your domain.

Then paste this value into the Cookiebot ID field of the Cookiebot CMP tag in GTM.

Google Consent Mode configuration
If you send your data to Google Ads, Google Analytics, or Floodlight, you need to enable Consent Mode in this Cookiebot CMP tag. To do this, check the Enable Google Consent Mode box and configure the default signals to denied.
Note however that this Consent Mode configuration is generic, and some specifics of your implementation may require additional adjustments.

Then trigger the Cookiebot CMP tag on Consent Initialization - All Pages.

Retrieving the Cookiebot consent state
To retrieve the consent state, we’ll use a variable available in the Google Tag Manager Web gallery called Cookiebot Consent State.
To do this, in GTM Web go to the Variables section, then click “New” to create a new variable in the User-Defined Variables section.

Then click on the blue banner to access the community variable template gallery.

Search for Cookiebot then select the Cookiebot Consent State template.

Then click on Add to workspace to add the variable template to your GTM Web container.

Confirm adding the variable template by clicking on Add.

Then create a new variable by selecting the Cookiebot Consent State template.
If you can’t select the Cookiebot Consent State variable, refresh the Google Tag Manager Web page and try again.

Once the variable is created, you can rename it to Cookiebot Consent State and save it. No additional configuration is needed.

Values returned by the Cookiebot Consent State variable
The Cookiebot Consent State variable returns a text string containing the consent state for each cookie category managed by Cookiebot.
Here is an example of the value returned by this variable:
|preferences|statistics|In this example, the user has consented to preferences and statistics cookies, but not to marketing cookies.
Listening for the consent update
The goal here is to detect the user’s consent update via Cookiebot and send an event to GTM Server to notify it of the new consent state. This way your server-side tags can be triggered as soon as the user gives their consent without having to wait for the next page load.
By default, Cookiebot sends a cookie_consent_update event to the dataLayer each time consent is updated. However, this event is also sent on every page load once consent has been given, which is not desirable in our case.
To avoid this, we’ll listen to the CookiebotOnAccept event which is only triggered when the user updates their consent. We’ll then push a custom consent_update event to the GTM Web dataLayer.
In your GTM Web container, create a new “Custom HTML” type tag to listen for Cookiebot consent changes. To do this, you can use the following code:
<script>
window.addEventListener("CookiebotOnAccept", function(event) {
if(event.currentTarget.CookieConsent.changed) {
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "consent_update"
});
}
});
</script>Then trigger this tag on Initialization - All Pages.

This way, each time the user allows one or more types of cookies via Cookiebot, a consent_update event will be pushed to the dataLayer.
On this event, we will then trigger a GA4 event tag to send a page_view event to GTM Server with the updated consent information.
This page_view event contains the custom parameter consent_status, which contains the consent state retrieved via the Cookiebot Consent State variable.

This GA4 event tag must be triggered on the consent_update custom event.

Configuring the GA4 Google Tag
The GA4 Google Tag must also send consent information to GTM Server. To do this, you need to add the consent_status event parameter.
Also note that this tag contains the configuration parameters send_page_view set to true and server_container_url with the URL of your server container.

Configuring other GA4 events
With the configuration done in the previous step, all your GA4 events should contain the consent_status parameter that lets you know the user’s consent state. However, it is important to add this parameter to all your GA4 event tags to ensure consent information is always present.
Here is an example of the add_to_cart GA4 event tag with the consent_status parameter added:

Configuration in GTM Server
Retrieving the Cookiebot consent state
To retrieve the consent state in GTM Server, we will create an Event Data type variable that will extract the value of the consent_status parameter sent from GTM Web.
Go to your GTM Server container, then in the Variables section, click New to create a new variable in the User-Defined Variables section.
Then select the Event Data variable type.

Conditioning a server tag on Cookiebot consent
We will condition the Meta Conversion API by Addingwell tag on Cookiebot consent. To do this, we will only trigger the tag when the consent_status Event Data variable contains the marketing cookie category, as this is the category most appropriate for the Meta platform.
To know whether you should condition a tag on user consent, refer to your DPO or your legal department.
In the trigger below, we check if the consent_status variable contains the value marketing, which indicates that the user has consented to marketing cookies.

Then add this trigger to your Meta Conversion API by Addingwell tag.

You have now conditioned the Meta Conversion API tag on Cookiebot consent. You can apply the same logic to condition other tags based on the appropriate consent categories.
Watch out for tags already fired before consent
If a user accepts marketing consent after browsing several pages, previous events (such as page_view) will not be sent retroactively to Meta. Only events following consent acceptance will be transmitted.
Verifying your implementation
Tag Assistant in Google Tag Manager Web
The first thing to check in the GTM Web preview (or Tag Assistant) is that the Cookiebot CMP tag fires correctly on all pages.

Next, check that the Custom HTML tag listening to the CookiebotOnAccept event fires correctly when you update consent via the Cookiebot banner.

Then check that the Cookiebot Consent State variable returns the consent state correctly.
If the value of this variable is empty, it means you haven’t yet given your consent via the Cookiebot banner. Give your consent to the different cookie categories so that the variable returns a value.

Now, interact with the Cookiebot banner to give your partial consent (one or more categories) or full consent (all categories).

Finally, check that the GA4 event tag fires correctly on the consent_update event.

And also that the consent_status parameter is present in this tag.

Google Tag Manager Server preview
In the GTM Server preview, check that the consent_status Event Data variable returns the consent state sent from GTM Web correctly on all your events.

Verify the reception of consent update page_view events with the consent_status parameter set to the latest consent value after giving your partial or full consent on the banner.

In this same page_view event, check that the Meta tag, or more generally your tags requiring consent, are properly configured.
If marketing consent has not been given, the Meta tag must not fire. It should then be in the Tags not fired section of your GTM Server preview.
Congratulations
Congratulations! You have successfully set up consent management with Cookiebot and Google Tag Manager Server. Your server-side tags are now conditioned based on user consent.
If you encounter any difficulty during these steps, do not hesitate to contact our support team.