Google Tag Manager

If you use Google Tag Manager (GTM) to inject cookies on your website, you can set it up so that the scripts are controlled by the consent preferences choices selected by visitors.

This makes deployment easier than using the standard helper methods described in the Client-Side Cookie Management section of this guide. However, there are some differences in behavior because of how GTM works.

This guide explains how to set up GTM to take advantage of these changes.

Note: This is not intended to be a complete guide to Google Tag Manager. Consult official Google Tag Manager documentation for more detailed information about setting up and using GTM.

Create a New Variable

  • Create a new User-Defined Variable
  • Name the variable. We suggest naming the variable CookiePro Active Groups so you know what it refers to
  • Set the Variable Type to Data Layer Variable under the Page Variables section
  • Set the Data Layer Variable Name to CookieProActiveGroups

Create Triggers

You will need a separate trigger for each cookie group you have set up.

For example, you may have a group in CookiePro called ‘Performance Cookies’, which has a group id of 2 and contains the cookies set by your Google Analytics tag.

  • Create a new trigger and name it accordingly, e.g. Performance Cookies Active
  • Set the Trigger type to Page View – DOM Ready
  • Set the trigger to fire on Some DOM Ready Events
  • Note:
    • In the right-most field, enter the group ids for which you want the trigger to apply as a comma delimited list (eg. ,2,4,9,). The group ids match the group ids assigned in the CookiePro Cookie Preference Center.
    • The inclusion of the commas is required.
  • Save the trigger
  • Apply the trigger to tags where you want the script to fire.

When you apply this rule to your Google Analytics tag, GA cookies will only be set if the Performance Cookies group is active in CookiePro. Similarly, you can set up a trigger for each of the different CookiePro Groups (Functional, Targeting, etc.) and apply those to the appropriate tags.

Create a Blocking Trigger

You can also set up cookie blocking rules to fire the script if a category of cookies is not active. For example, set a trigger to fire when OneTrust Active Groups does not contain 2 (where 2 is the id for performance cookies). Apply this blocking trigger as an exception to tags in this group.
  • Create a new trigger and name it accordingly, e.g. Block Performance Cookies
  • Set the Trigger type to Custom Event
  • Set the Event name to .* and check the box for Use regex matching
  • Set the trigger to fire on Some Custom Events
  • Fire the trigger when the following is true:
    [CookiePro Active Groups] [does not match RegEx] [,2,]
  • Save the trigger
  • Apply the trigger to tags as an exception
Note: In the right-most field, enter the group numbers for which you do not want the trigger to apply as a comma delimited list (e.g. 2,4,9,). The group numbers match the group numbers assigned in the CookiePro Cookie Preference Center.
  • Save the trigger
  • Apply the trigger to tags as an exception

Words form our Customers

Testimonials