Prevent triggers from firing in GTM
How to prevent triggers from firing, if consent has not been given on certain or all cookie categories.
Last updated
How to prevent triggers from firing, if consent has not been given on certain or all cookie categories.
Last updated
This courtesy guide is no longer actively tested by Openli, although it might still work.
Our cookie-consent widget intentionally uses a highly-compatible, highly-generic approach to integration. In most cases, it will be possible for your developers to adapt this guide's steps to any changes that might have been made to the target platform, in combination with their own general documentation. Our consent-state events might be useful for this.
We have developed an API, which returns the current cookie consent state. This API can be used in a GTM Custom JavaScript variable to decide whether or not a trigger should fire.
First step is to create a new variable, and select variable type Custom Javascript
.
In the created variable, paste following snippet:
For marketing triggers, simply replace the analytics
property in the snippet with the marketing
property.
After pasting the snippet, save the variable with a name of your choosing.
Select your desired tag, and then add or edit a trigger.
In your trigger, choose the option like Some <actions>
under This trigger fires on
.
In the conditional selection list that appears, choose your newly created Custom Variable (will be by the name you have given it).
The next selection box should be set to equals
.
Lastly, write true
in the last box.
Save the trigger, and publish.
Your selected triggers will now only fire when user has consented to chosen categories.