theFrontEndDev
theFrontEndDev

Reputation: 973

How to Trigger a GTM event based on Cookie is accepted or not

There is a piece of script in GTM ( as tag ) that needs to trigger only when user accepts a particular cookie. Problem is - I have added a script belonging to the particular cookie category via GTM. When a user wants to accept only analytics ( GTM loads as expected ), the script I have added via GTM which belongs to another cookie category ( not analytics ) also fires ( Ideally it shouldn't cos only analytics is accepted by the user ) . Is there a way to trigger GTM event only when cookie is accepted.

Upvotes: 1

Views: 2844

Answers (1)

XTOTHEL
XTOTHEL

Reputation: 5198

If I understood correctly, you're looking to load the functional script ONLY if they accept AND functional cookie is 'yes'

In GTM, there are "Variables" that can keep track of 1st party cookies. So in y our case you would want to:

Create a variable to track the functional cookie value enter image description here

create the trigger based on clicking on "accept" and it would just be conditional based on the value being "yes" (you will need to create your custom functional script tag beforehand) enter image description here

Add the trigger to the functional tag enter image description here

Upvotes: 1

Related Questions