Highlighted

trigger tags after cookie consent is accepted with 3rd party vendor (OneTrust)

Bronze Contributor
Bronze Contributor

hello - we are working through a OneTrust cookie consent manager implementation on our sites. the tag is implemented within Tealium and we have a cp.variable capturing which cookie categories the user opted into, to trigger our tags. Right now, when the cookie is accepted, the tags do not fire until you interact with the site in some way. Is there a way to trigger the tags to fire once the user accepts the cookie consent? 

My thought is that we would likely need to make a manual utag.view call using a JavaScript extension when the cookies are accepted, but not sure how to set that up. I looked into referecing the cp.variable we created, but that does not appear to included/updated in the data layer until the user interacts with the site after accepting or declining the cookie consent.  

Any help would be appreciated.

Thanks, 

2 REPLIES 2
Highlighted

trigger tags after cookie consent is accepted with 3rd party vendor (OneTrust)

Tealium Employee

That is correct! You will manually need to trigger a utag,view() call once the user opts-in. In this utag.view() call, you will need to pass the utag_data object or any variable that contains the data layer for that page.

Once the utag.js file runs, it will automatically read the OneTrust cookie and place it into the appropriate cp.{variable}. This variable can then be used as a load rule for the tags.

Highlighted

trigger tags after cookie consent is accepted with 3rd party vendor (OneTrust)

Tealium Employee

Hi @bresulli 

You are correct that you would want to trigger a manual view call with utag.view(). 

1. If you have jQuery implemented on your site, you could use the jQuery Extension to target the Submit Button,

mattressfirm | dwmattressfirm 2020-05-15 10-25-06.png 

2. or you could use a javascript extension and set up an event listener:

document.getElementById('ConsentButton').addEventListener('mousedown', function () {
  utag.view()
});

3.  Or ideally, you could have a developer option #1 or #2 from within your source code.

 

Once the Submit button is clicked, utag.view will fire, the OptanonCookie will be set and the cookie can be leveraged with Load Rules for each Category.  With the Load Rules applied to each tag, the Tags will fire according to what the use has chosen.

 

Please let me know if this helps.