How to block cookies with multiple GTM triggers

Avatar

By Manish Gautam

updated 2 months ago

While using Google Tag Manager, there can be Tags with multiple triggers. This article explains how we can block cookies with multiple Triggers.

In GTM, a tag will fire if all of the triggers conditions on a tag evaluate to true. Sno you must add a condition to the existing trigger by adding a user-defined variable. Trigger conditions must all evaluate to true for the trigger to fire. 

Here is an example of adding a consent condition to an existing trigger: 

1. Create a user-defined variable and name it "sp_user_consent". In the field "Custom Javascript", enter the following snippet:
 
function(){
return window.dataLayer.map(function(m){ return m.event;}).join(',');
}

Screenshot_2019-04-12_at_12.38.54_PM.png

 

2. Modify your custom event trigger configuration as shown below. The values of the cookie consent trigger condition to add are: Event - contains - {{Plugin name}}  


Screenshot_2019-04-12_at_12.28.08_PM.png

 
 
Note: If your existing trigger is of the event type "Page View", you need to change it to event type "Window Loaded" since the visitor's consent is not available to GTM before the window has loaded.

Did this answer your question?