Queue Tealium events

Gold Contributor
Gold Contributor

Hi

we are currently implementing a new CMP solution on our website. In general, checking consent from Tealium and respecting this in the load rules is working as intended. However, I am not sure how to handle the situation of the initial events, which are triggered while the consent overlay is not yet accepted by the user.

Currently, these events would be discarded, as the consent is not yet given at this time. Is there a possibility to somehow queue these events while consent is not yet available and then trigger these events again as soon as this is the case?

Did anyone implement something similar? Does Tealium provide some built-in functionality for this case?

Best regards,

Andreas

3 REPLIES 3

Queue Tealium events

Moderator
Moderator

Hi @ahrasch - we're finishing up our 'Consent Integrations', which we're expecting to EA in Q4 - what CMP are you using? Feel free to DM me!

Queue Tealium events

Tealium Expert
Tealium Expert

Depends on how your cookie manager is integrated, but hypothetically, one way to do it would be:

  1. Use a Before Load Rules tag to store inbound events in an array
    utag.cachedEvents = utag.cachedEvents || [];
    utag.cachedEvents.push([a, JSON.stringify(b)]);
  2. Create a function that will run through those and re-send them
    utag.sendCachedEvents = function(){

    // Nothing to do if nothing is cached
    if(utag.cachedEvents.length === 0) return;

    // Effectively disable sending on all tags that already loaded
    // There will be smarter ways of doing this!
    Object.keys(utag.sender).forEach(function(tagId){
    var tagObject = utag.sender[tagId];
    if(tagObject.ev){
    tagObject.ev_old = tagObject.ev;
    tagObject.ev = {};
    }
    });

    // For every cached event we've got
    utag.cachedEvents.forEach(function(event,eventIndex,eventArray){
    // Grab the original event details from the cache
    var eventType = event[0];
    var eventPayload = JSON.parse(event[1]);

    // Flag if this is the last cached event so we can re-enable those tags
    if(eventIndex == eventArray.length - 1) eventPayload.finalCachedEvent = true;

    // Trigger a send for each of the events
    utag[eventType](eventPayload);

    });
    };
  3. Then you'll want an After Tags extension that will fix up the mess we created of the tag event objects above:
    if(b.finalCachedEvent){
    Object.keys(utag.sender).forEach(function(tagId){
    var tagObject = utag.sender[tagId];
    if(tagObject.ev_old){
    tagObject.ev = tagObject.ev_old;
    }
    });
    }
  4. Then just hook the function in step #2 into the cookie consent update

So what we're doing here is first storing events as they come in in case we need to replay them later, then when we attempt to replay them we hack the existing set of loaded tags to disable sending (this is a terrible way to do it and won't work on bundled tags that are subject to consents because it'll disable them even though they didn't fire yet, there's ways to code around that but this is just a quick and dirty demo..), so that we can replay those events back through in sequence (you may wish to async/await some delays between the sends if you feel you need it) without them re-triggering any of the tags that already loaded, in theory then only firing against tags that were previously out of scope and have now come into scope. And then finally, once the last of those payloads passes through the event process and hits the After Tags extensions, we put the tags' event flags back where they were before and all future events will run against them just fine.

There's all kinds of edge cases that this doesn't accommodate, particularly if any of your global extensions have side effects, or are intended only to run once, but broadly speaking, in a simple implementation, it disables any tags that already fired, re-runs the events so far, and then re-enables everything, in a way that does what you're after..

Queue Tealium events

Gold Contributor
Gold Contributor

Thank you for your comprehensive suggestion. I also take that as an answer that Tealium currently doesn't provide a feature out of the box to support this :)

We will be using Onetrust as our CMP provider. I know from a previous talk with our CSM that Tealium is partnering with a different CMP provider. So we will see if the upcoming Consent Integrations feature will help us to simplify our solution.

For now we will build something like suggested. Thanks again for your respones.

Best regards,

Andreas

Public