Skip to main content
All CollectionsCustomization and advanced settingsContent and tag templates
Integrate Cookie Information Consent Management Platform with Google Tag Manager
Integrate Cookie Information Consent Management Platform with Google Tag Manager

Learn how to integrate Cookie Information Consent Management Platform with Google Tag Manager (GTM).

Updated over a month ago

To manage when tags trigger and handle cookie consent, integrate the Cookie Information Consent Management Platform (CMP) with Google Tag Manager (GTM). This setup uses triggers and variables to ensure that tags, such as those for analytics and marketing, only activate after users give consent for specific cookie categories, helping maintain privacy compliance.

In this article, we’ll show you how to integrate the Cookie Information Consent Management Platform with Google Tag Manager.

Before you start

Here are a few things to know before you start:

  • To integrate Google Tag Manager with Cookie information, you’ll need a Google Tag Manager account. To create one, visit tagmanager.google.com and follow the instructions on that page.

  • Google Tag Manager uses tags that are activated by triggers. Triggers are events on your website, like button clicks or visits to specific URLs. The most common trigger in Google Tag Manager is a page view, which by default will fire a tag on all pages of your website.

  • By default, there are three cookie categories which the users can consent to:

    • cookie_cat_functional

    • cookie_cat_statistic

    • cookie_cat_marketing

You use them as triggers’ event names later.

  • When a visitor accepts cookies, we push an event related to each consented category to the Google Tag Manager data layer. You can use this data to set up custom event triggers.

Here’s an example of such a data layer:

mceclip0.png
  • To integrate Cookie Information CMP with Google Tag Manager, you’ll need to create:

    • A set of custom triggers

    • A set of custom JavaScript variables

    • A set of tags

Assign these triggers and variables to your existing tags to prevent them from firing

when a user first visits the site. The tags will activate once the user gives consent.

  • If you want page view triggers to activate only after consent for a specific category is given, replace them with custom event triggers based on cookie_cat_* data layer events. For other trigger types used by your tags, like custom event or click triggers, you'll need to create modified versions of these triggers.

    Add extra conditions based on variables tied to visitor consent choices. For this purpose, you need to use user-defined variables.

Integrate Cookie Information Consent Management Platform with Google Tag Manager

To integrate Cookie Information Consent Management Platform with Google Tag Manager, follow these steps:

  1. Log in to your Google Tag Manager account.

  2. Navigate to the menu and click Triggers.

  3. Click New.

Add a new trigger


4. Name the trigger.


5. Click on the Trigger Configuration window and choose Custom Event.

6. Set the trigger's event name to match one of the existing cookie categories listed in the Before you start section. In our case it’s cookie_cat_statistic.

Note: If you encounter type errors, remember that the data layer is case-sensitive. Make sure to type categories correctly.

7. Select All Custom Events.

Setting up the event name

8. Click Save.

9. Repeat steps 2-8 to make two additional triggers for the other two consent categories.

Note: You only need three custom triggers because the 'necessary' category always fires automatically, so there's no need to create a separate trigger.

The following steps are optional for events other than page view.

10. Navigate to Variables.

11. In User-Defined Variables click New.


12. Name your variable and click the Variable Configuration section.

13. Select Custom JavaScript variable.

14. In Variable Configuration > Custom JavaScript section, paste the following code:

function() {
return window.CookieInformation.getConsentGivenFor('cookie_cat_functional');
}

add custom JavaScript

15. Click Save.

16. Repeat the steps with variables for the other two cookie categories: cookie_cat_statistic and cookie_cat_marketing, if you need to collect consent for marketing and statistic purposes.

Note: In the following steps we're showing here just an example of how to use custom variables for events other than page views. You don’t need to use the needs to exact data and parameters as in the instructions below.

17. Navigate to Triggers and click New.

18. Name the trigger and click the Triggering section.

Variable configuration


19. Choose All Elements trigger.

20. In Trigger Configuration, select Some Clicks.

trigger configuration


21. Set the following trigger conditions:

trigger conditions

22. Done.

Related articles:

Did this answer your question?