Articles on: Integrations

Integration with Google Tag Manager

Google Tag Manager (GTM) is a tool that allows you to manage and deploy tags (snippets of code or tracking pixels) on your website without having to modify your site code.

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

In this article you will learn the following:

How it works
Create new variables
Create new triggers
Adding the triggers to tags

How it Works



To pass data to Google Tag Manager, our application uses the custom consent event through the Data Layer Variable.



Our application uses the existing dataLayer object or creates a new one if it doesn’t already exist. If your store creates a dataLayer object, ensure that this does not overwrite the one our application creates.

You can also rename this property to any custom property you have used. This is available as an option inside the GTM integration form of our app.

Create new variables



Open your container in Google Tag Manager.
Select the Variables tab from the main menu. The Variable screen appears.
Create a new User-Defined Variable.
Name the variable. (We suggest naming the variable Pandectes C000x where x is the number of the category found here 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 pandectes_categories.C000x where is the number of the category found here (for example for the category Functionality you can put pandectes_categories.C0001).



Press the Save button.

You can follow the same process creating one new variable for all the categories of your app and finally have here 4 variables in total.

Create new triggers



In GTM, triggers prompt tags to fire or not fire on certain criteria. You may already have a variety of different triggers applied to your tags.

As part of our Google Consent Mode integration with GTM, you are going to create a trigger associated with each cookie category.

When you apply these triggers to your tags, this will prompt your tags to fire or not fire based on the Cookie Category being active or the consent given by the user.

You will need a separate trigger for each of the Cookie Categories that you will be blocking cookies under. For example, you may have a group called 'Performance Cookies', which has a category id of C0002 and contains the cookies set by your Google Analytics tag.

Each trigger needs to be in line with the category ids that are set in your cookie consent application. You can find the cookie category IDs in the custom consent event here and in the Google Consent Mode integration section inside the app where there is a structure popup of the custom consent event.

We want the cookie category id triggers that you create to be applied to your existing tags in such a way that our app's trigger is the limiting factor to the tag firing. This can be done in several different ways. Two different ways are outlined below.

Creating a Firing Trigger



Open your container in Google Tag Manager.
Select the Triggers tab from the main menu. The Triggers screen appears.
Press New. The Trigger Configuration screen appears.
Name it accordingly, e.g. Pandectes Performance Allowed.
Press the Trigger Configuration and set the Trigger type to Custom Event.
Set the Event name to Pandectes_Consent_Update.
Select Some Custom Events and set it to fire when the following is true:


Pandectes C0001 equals allow




Save the Trigger.
Repeat this process for the remaining Cookie Categories.
Apply the Triggers to Tags as a firing trigger.

Note: If a tag is blocked and then allowed, it'll fire without the need for a page reload because of listening for Pandectes_Consent_Update. If it had been previously allowed and then blocked, the tag would be blocked on subsequent page loads.

Creating Exception Triggers



You can also set up an exception trigger to fire the script if a category of cookies is not allowed.

You will only want to use an exception trigger if you already have a different firing trigger set up on your tag.

For example, set a trigger to fire when Pandectes_Consent_Update does not allow C0002 (where C0002 is the id for the performance category). Apply this blocking trigger as an exception to tags in this group.

Select the Triggers tab from the main menu. The Triggers screen appears.
Press New. The Trigger Configuration screen appears.
Create a new trigger and name it accordingly, e.g. Pandectes Performance Blocked.
Press the Trigger Configuration and set the Trigger type to Custom Event.
Set the Event name to Pandectes_Consent_Update.
Select Some Custom Events and set it to fire when the following is true:


Pandectes C0001 equals deny




Save the Trigger.
Repeat this process for the remaining Cookie Categories.
Apply the Triggers to Tags as exception triggers.

Adding the triggers to tags



On the main navigation menu in Google Tag Manager, select Tags.
Select a tag to apply the appropriate Pandectes Cookie Category Trigger too.
Apply the appropriate Firing Trigger or Exception Trigger that you have created.
Click the Save button.

Updated on: 17/12/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!