Considering consent state (GDPR) on utag.track (view/link) calls

Sam
Silver Contributor
Silver Contributor Sam

Hello,

I'm currently implementing the consent prompt and preferences dialog at a client.
However, I'm running into an issue while forcing tags to load by calling for example :

utag.view({ ... }, null, [123])

This code will force tag 123 to load, no matter what load rules are configured, and it will also ignore any choice in the consent manager. What I'm trying to achieve is that the tag would not be fired by this method call, if the tag is in a disabled category in the consent manager.

I couldn't find any configuration for the view/link/track methods that would allow this behaviour, ideally I'd be able to add a flag that signifies that consent choices should be taken into account. As alternatives that I could implement myself, I'm thinking about 2 strategies:

Intercept utag.track
My first idea is to overwrite utag.track and check which IDs are present in argument (if any). Then, I could remove those IDs that should not be loaded, or prevent the event completely if no IDs are left in the list. To do this, I found utag.loader.cfg, this gives me a list of all tags and some loading configuration. From this post (click here) I gather that if the "load" property is not 0, the tag can be fired, but I'm not sure if this logic is correct and safe.

Secure all calls to track/view/link
Another idea is to just surround all calls to these methods with an additional if statement to see if the tag is allowed to load based on the consent choices. Even though we do not have that many calls to these methods where we supply a list of tags to force load, I would like to find a different way to get this functionality.

I'd prefer to implement something similar to the first method. What I'm most scared of is that I'd break something, and some tags might not load. In the future, if this functionality would cause any trouble for tags not loading, it may be hard to find the cause, especially for someone who is not aware that this was implemented or how it works.

I'm hoping there's another way to get what I need, so that I can disregard my previous options.

Many thanks to anyone taking the time to read this!

Kind regards,
Sam

 

4 REPLIES 4

Considering consent state (GDPR) on utag.track (view/link) calls

Tealium Employee

HI Sam,

We generally don't recommend calling the tags with their IDs. In this case you could call a custom for instance utag.track("yourevent",...) and in the template of the tag add that event to the u.ev object

u.ev = {

"view": 1,

"yourevent":1
};

As far as I know this method would respect consent. It also allows for a tag changing their UID or libraries. As opposed to other methods you suggest it doesn't involve changing core functions of utag so it is more robust.

Hopefully this helps you!

Considering consent state (GDPR) on utag.track (view/link) calls

Tealium Employee

Hi @Sam ,

 

Adding a function in an extension like this might do the job for you,

 

utag.linkConsent = function(data, cb, tags){

    if (utag.gdpr){
        var consentState = utag.gdpr.getConsentState();
        var csTYpe = utag.gdpr.typeOf(consentState);
        var sendTags = [];
        for (var i = 0; i<tags.length;i++){
            var id = tags[i];
            if (typeof utag.loader.cfg[id] !== "undefined" && ((csTYpe === "array" && consentState[tag.tcat - 1].ct == "1") || (csTYpe === "number" && consentState == 1)) || (utag.gdpr.omittedTags && !utag.gdpr.omittedTags[id])){
                sendTags.push(id);
            }
        }      
    }
        
    var sendTags = sendTags || tags;
    if (sendTags.length > 0){
        utag.link( data, cb, sendTags);
    }    
}

You would call this in a similar way to how you currently call the tags directly.

utag.linkConsent({"hello" : "world"}, null, [9])

The issue with the consent is that whent consent is checked, it modifies the loadrules of the tags and sets them to "false" for any tags the consent is not met for - however calling tags directly like this ignores the consent.

The function provided above replicates the consent check, but instead of adjusting the loadrule, it removes any unwanted tags from the array of UID's to be loaded.
If consent manager is not active - it will load all of the tags.

 

The example given above was quickly put together - it's obviously only set up for a "link" event, but you could either replicate this for "view" or modify it for a generic "track" function - just a proof of concept for you to adjust as needed.

It worked on my test profile quickly, but you may run in to a few issues if you test it a bit more vigorously.

Considering consent state (GDPR) on utag.track (view/link) calls

Sam
Silver Contributor
Silver Contributor Sam

Hey @tculetto @LordLingham ,

Thank you for both of your answers!
I prefer the answer by @tculetto , this way I can use a custom event, and modify the template by adding something to the start of the `send` function. There, I could check if the value of `a` is my custom event, then I can simply set the value of `a` to "view", and it will treat the rest of the event as a pageview!

I never thought about custom events, that's smart :)

Thanks!

Kind regards,
Sam Van Renterghem

Highlighted

Considering consent state (GDPR) on utag.track (view/link) calls

Tealium Employee

Hi @Sam 

 

Thanks for your feedback!

I've recently been informed on a function which was included in a recent update to the consent manager which actually does this functionality for you (honoring consent on events like these).

Are you running V2 of consent manager?

If so - delete the "cmGeneral" template and then publish - to get the template to update to the latest version.

If you are not - reach out to me in a private message, or raise a ticket with support and we can get your profile updated!