How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

loldenburg
Silver Contributor
Silver Contributor loldenburg

I know we can stop a certain tag from firing by scoping an Extension to Tag X and have this Extension return false.

But how do we do this for ALL Tags?

The use case is:

A client's website keeps firing utag.view Events at some points where those should not be fired. Waiting for the release to fix this will take months. We send those Events to all kinds of tools. 

We can identify the false events easily (they are Cart View Events even though the user is not in the Cart), but how can we tell Tealium "stop execution for all Tags" in an All Tags Extension? Returning false in an All Tags Extension does not abort execution for All Tags like it does when it is scoped to a certain tag.

So in short: We COULD create an Extension like that and scope it to all tags manually by adding in all the tags in question, but that seems like a waste of code (the extension code is then duplicated for all those tags) and it is also less sustainable as new tags would not be part of the Extension and we would have to think about adding them each time we create a new tag.

There must be something more elegant.

8 REPLIES 8
Highlighted

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

Tealium Expert
Tealium Expert

My suggestion here:

https://community.tealiumiq.com/t5/Tealium-iQ-Tag-Management/Hard-coded-UID-value-in-utag-view-call-...

Would work for this.. You could put a wrapper around utag.view, effectively replacing the function, and then conditionally abort it (i.e. fail to call utag.track) if the conditions for "do not send" were met.

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

loldenburg
Silver Contributor
Silver Contributor loldenburg
That's slick, thanks a lot! However, that is quite a brutal method to override standard Tealium functionality for this simple purpose I have in mind. Tealium Developers of the future may hate me for such a hack... So I will look out for something less invasive.

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

JohanAlm
Silver Contributor
Silver Contributor JohanAlm

Hi @loldenburg 

I had a similar situation only from the Tealium SDK in Android App. We kept getting double server calls where one is "utag.view/link" and the other is "remote_api". These extra calls are for the Tealium TagBridge and unless you need them should be ignored. No tag was firing based on this call but it did pass through all our code and in some cases causing extra increase to counters since two server calls contains the variableX++ and so on. 

The solution here is similar to what you want to achieve for a tag scoped extension where you can return false. More or less it looks at the call and determines if it should be used or thrown. Here is the code I am using:

if(typeof(window.oldTrack) != 'function') {
    window.utag = window.utag || {};
    utag.oldTrack = utag.track;
    utag.track = function(a, b) {
        if (a == "remote_api") {
            return;
        } else {
            utag.oldTrack(a, b);
        }
    }
}

Test it thouroughly before using to make sure it isn't causing anything unexpected. Even though my setup is for App, I expect it should be possible to use on a web setup as well.

 

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

loldenburg
Silver Contributor
Silver Contributor loldenburg
thanks @JohanAlm, this is great feedback. I still would like a solution that does not require overriding native Tealium functions, but it seems this is the only way to do it.

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

harm_te_molder
Bronze Contributor
Bronze Contributor harm_te_molder

I'm trying to achieve this same behavior. In my case it's blocking utag.view calls when widget_name is in the list supportiveWidgets:

(function blockSupportiveWidgets(a, b) {
    if (
        a === "view" &&
        ((b.state_name != null && b.state_name === "init:state") ||
            (b.event_name != null && b.event_name === "init:state"))
    ) {
        var supportiveWidgets = ["chat-client-nl-widget-ec"];

        if (
            b.widget_name != null &&
            supportiveWidgets.indexOf(b.widget_name) > -1
        ) {
            utag.DB(
                "blockSupportiveWidgets - utag."
                .concat(a, " call from ")
                .concat(
                    b.widget_name,
                    " blocked because it's in the list of supportive widgets ("
                )
                .concat(supportiveWidgets.join(), ")")
            );
            utag.loader.cfgsort = [];
        }
    }
})(a, b);

Setting utag.loader.cfgsort to an empty array seems to do the trick, but I'm still testing before it's production-ready. Will let you know how that goes.

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

loldenburg
Silver Contributor
Silver Contributor loldenburg
Hmmm that's fascinating, but it looks like a rather brutal hack, and having TMS code that relies on Babel or other libraries is also not recommended, it makes the code slower and you never know where that code may end up (e.g. on a website without Babel support). Trusting on Babel alone often still does not suffice for IE11.

So I on the one hand appreciate your development skills, but I would not advocate such a solution for a sustainable, big-company-type Tealium implementation.

Tealium should offer their native function for that. Everything else I have seen here so far are hacks which may sooner or later fall on our heads.

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

harm_te_molder
Bronze Contributor
Bronze Contributor harm_te_molder

I ended up using a tag-scoped extension that returns false, as @loldenburg mentioned in his original post, which I'll paste here for reference:

function duplicatePageViewHack(b) {
  var sendPageView = true;
  var cooldownSeconds = 2;
  var currentPageView = {
    "dom.pathname": b["dom.pathname"],
    tealium_timestamp_epoch: b.tealium_timestamp_epoch
  };
  /* Make sure no pageviews are sent from this list of widgets */

  if (
    b.widget_name != null &&
    [
      "chat-client-nl-widget-ec",
      "personal-contact-info-widget-sc",
      "content-widget-mijn-abnamro",
      "content-widget-my-abnamro",
      "chat-client-nl-widget-wpp",
      "content-widget-my-abnamro-business"
    ].indexOf(b.widget_name) > -1
  ) {
    sendPageView = false;
    utag.DB(
      'duplicatePageViewHack: No Adobe Analytics page view because widget_name "'.concat(
        b.widget_name,
        '" is on the blacklist'
      )
    );
  } else if (sessionStorage.tealium_last_pageview != null) {
    /* Make sure no pageviews are sent during the cooldown period following a pageview from the same page */
    var lastPageView = JSON.parse(
      sessionStorage.getItem("tealium_last_pageview")
    );

    if (
      lastPageView["dom.pathname"] === currentPageView["dom.pathname"] &&
      currentPageView.tealium_timestamp_epoch -
        lastPageView.tealium_timestamp_epoch <
        cooldownSeconds
    ) {
      sendPageView = false;
      utag.DB(
        "duplicatePageViewHack: No Adobe Analytics page view because the previous page view from this page was less than ".concat(
          cooldownSeconds,
          " seconds ago"
        )
      );
    }
  }

  if (sendPageView) {
    sessionStorage.setItem(
      "tealium_last_pageview",
      JSON.stringify(currentPageView)
    );
  }

  return sendPageView;
}

return duplicatePageViewHack(b);

How to stop Tealium within an All Tags Extensions if I want to abort a utag.view or .link Event?

harm_te_molder
Bronze Contributor
Bronze Contributor harm_te_molder

I agree that this is functionality that Tealium should provide, but in case anyone wants to try this brutal hack, I've run it through Babel myself and pasted the result here.