The Cookie Control SDK is enabled via the custom trigger, events and tags functions in Google Tag Manager(GTM)
The different triggers, events, and tags are fired by the consent pop-up which also includes all the necessary logic.
By default, there are 3 basic cookie categories which your users can consent to:
Those will also serve as triggers and event names.
Step 1 - Setting up triggers
1. Navigate to the main dashboard, click "Triggers" section, and select "New"
2. Select "Custom Event" trigger from the list
3. Fill in the required inputs:
Use one of the existing cookie categories listed above as the trigger's event name, e.g. "cookie_cat_marketing"
The trigger itself, however, does not need to use the category name.
4. Repeat the steps above for all individual cookie categories to cover all the possible
choices of the end-user.
Step 2 - Setting up tags
Now, with all triggers configure, we can continue and assign the content/functionalities we want to
serve on our website.
In this example, we'll use Google Analytics.
1. Start by choosing the type of tags you want to use. In this example, it’s Universal Google Analytics, but it could be any other tag
2. Configure the tag according to your needs, and select a relevant trigger. In this example,
as we're configuring Google Analytics, we should use the cookie_cat_statistic event, which
was assigned to a trigger called "Statistic Cookie".
Remember that a trigger's event name is a key value, while the name of the trigger can be set according to your preferences and will not affect the trigger’s functionality.
- A tag can be called using a number of triggers. If more than one trigger is added, Google
Tag Manager will require at least one of them to fire to execute the tag.
- Additionally, you can set how many times a tag can be triggered per a client’s visit.
- Remember to publish your changes or the tag will not work as expected.
Using Multiple triggers
In GTM you can't set up more than one triggers because that only ONE trigger has to equal TRUE for the tag to fire.
Therefore you will need to set our custom event as a condition for the main trigger.
Use the built-in variable: Event and set to be equal to [cookie category]
When you can't use a custom event
Some tags can't take custom events as a trigger. eg click element or click links.
Change the cookie category accordingly
The function will return TRUE or FALSE