How to make sure a tag is only fired once?

Silver Contributor
Silver Contributor
We have in place an EU Cookie Control policy in place, so visitors get an optional dialog to accept cookies, which allows the customer to actively select if he accepts cookies or not. We have tags that is allowed to be executed not taking into account the selection, and we have tags that's only allowed to be executed once a customer accepts the policy. We have set up a datasource indicating if cookies are accepted, this is being added to the datalayer before the utag.js is being loaded, so it's not a problem to manage as soon as the selection has been made on a previous page, however the problem is only on the first visit. While testing we simply loaded utag.js and when a customer accepted cookies, we would send a utag.view(), however any tags that supports and has executed once will execute again based on this. Ideally I would like to solve it by being able to send some kind of event through, which would trigger these tags to be executed, since that is what we're capable off from within our cookie policy component. I can probably fix it by modifying the templates, however I also want to make it simple for the users of the interface to easy add new tag rules. Thanks in advance /Lars
4 REPLIES 4

How to make sure a tag is only fired once?

Moderator
Moderator

Hi Lars,

 

The Tealium Privacy Manager allows you to do exactly what you are asking for. It could be that you can use this in conjunction with your cookie popup. Have a look here and see if you think it could help: Privacy Manager Extension

 

I've done some work with the privacy manager recently, and it is very customisable. The default behaviour is to place a button on the page that the user has to actively click, but it's possible to call it also through javascript in response to another action on the page (such as clicking your "I accept" cookies option). If you would like to discuss in more detail once you've reviewed the documentation, please message me and we can discuss further.

 

It's also possible to turn off the default page view in Tealium (even just for specific pages if this is required), which would be another way to stop the tags from firing twice - only your utag.view() call would then trigger the tags.

 

Craig

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

How to make sure a tag is only fired once?

Silver Contributor
Silver Contributor
Thanks for the hint Craig, I did test it out, but there was still a gap in what it provided and what I wanted to achieve. A scenario is, that we have some tags, we only allow these to be fired when the policy is accepted. This tag will be fired on a specific URL when the user enters the platform the first time. The user is presented with the Cookie Policy, for all users that accepts it the tag is immediately fired, since it has been queued via our JavaScript component. It seems like the Privacy Manager simply drops a cookie and when the user visit another page or reloads the page, this cookie is consulted. In the above scenario, that would result in my tag never getting again, unless the user manually reloads the page. /Lars

How to make sure a tag is only fired once?

Employee Emeritus
Lars, Thanks for these details. For now, you may have to open up an new "hidden" iframe on the landing page (an iframe in your domain) that will run the utag.js again on the landing page. This will allow utag.js to read the cookies and fire the tags on the first page of the user's visit (before moving to a new page.) This is probably not the ideal solution. Craig's solution may also work. I think this is what he is describing.. (1) Preloader Extension: // if this is the landing page (no cookies set yet) window.utag_cfg_ovrd = {noview : true}; (2) Show privacy solution (3) Call utag.view to fire tags One final note, we're working on a new utag.js template that will re-evaluate load rules with a utag.view call. This would allow you to call utag.view to "load" in new tags after they've adjusted their privacy settings.

How to make sure a tag is only fired once?

Employee Emeritus
If you know that your visitor is "Opted In" to everything (from a legacy cookie or a server-side value) you can override the Tealium Privacy Manager Extension. // Assuming that utag_data (Data Layer) is in the HTML source above utag.js // Requires: // (1) This Extension is scoped to "PreLoader" // (2) This Extension is listed *below* the "Privacy Manager" Extension in the UI. This is important. // (3) Data Layer has a value that indicates if the server knows the visitor has already opted in // utag_data.optedin=true; if(utag_data.optedin){ // expire OPTOUTMULTI cookie document.cookie = 'OPTOUTMULTI=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; }
Public