How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Gold Contributor
Gold Contributor
Hi, we have a Tealium setup with a (default) automatic utag.view. That's fine for us, but we want to block/inhibit it for a certain page (to inhibit SiteCatalyst request). We plan to do this in an extension (so noview on configuration is not an option). Thanks! Alessandro
8 REPLIES 8

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Moderator
Moderator

Hi Alessandro,

Could you use a load rule for this to prevent SiteCatalyst from loading on the URL in question? That would be the best way in my opinion, unless there's a good reason why the load rule will not do the job. Perhaps you can give us some more information on the problem?

There is also a way to prevent tags from firing by using a special javascript extension scoped to the tag, but I would only use this as a last resort; what you've described should be possible with load rules.

If you want to block all tags from loading on this particular page, you can wrap the "noview" option inside an if statement so that it only gets set on a particular url e.g.

if (window.location.pathname === "/home"){
  window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};
  window.utag_cfg_ovrd.noview = true;
}

If you use this option, this code must be in an extension scoped to pre-loader.

Thanks,

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 inhibit/block utag.view automatic call in an extension only on certain conditions?

Gold Contributor
Gold Contributor
Thanks, Craig. I did it just like you suggested, creating a load rule for SiteCatalyst with a "url doesn't contain" conditions. Worked like a charm! Alessandro

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Gold Contributor
Gold Contributor
Hi Craig, if we use a load rule, the tag is not available in case of any needs (for instance if we need to track a click) on that page. So, I'm interested in the 2nd solution you mentioned (extension scoped to the specific tag), can you provide more details? It could save me!! Thanks

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Tealium Employee

Hi Jarno,

If you scope a JavaScript extension to a tag and the return value is a boolean false, it should prevent the tag from firing. For example:

if (window.location.pathname === "/home"){
return false;
}

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Gold Contributor
Gold Contributor
That's great! Can anyone of Tealium staff confirm if this solution is sturdy enough or not? Thank you!

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Bronze Contributor
Bronze Contributor
Hello,
 
I want to have similar solution but with one small change, I want to load only one tag and block all the other tags being triggered from this page? Is this possible?
 
Thanks!
Megha

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Tealium Expert
Tealium Expert

Hi @meghashri,

Off the top of my head, you could use a pre-loader extension that conditionally sets:

window.utag_cfg_ovrd = window.utag_cfg_ovrd || {};
window.utag_cfg_ovrd.noview = true;

This should block the automatic utag.view event on page load, thus suppressing all tags by default.

Then you would need to fire a manual view, e.g. at DOM Ready, along the lines of:

utag.view(utag.data, null, [7]);

Where that third argument is an array which contains the tag IDs of the tags you want to fire (in this case, the one tag you don't want to suppress). The following caveats do apply:

  1. The tag you specify will fire irrespective of load rules, so if you need to fire it conditionally, that logic will have to set in your DOM Ready extension
  2. When you specify an array of tag IDs, because load rules are bypassed, TIQ also bypasses Before Load Rules extensions. So if you have any data preparation work going on in your BLR extensions, you'll need to either mirror it into ALR extensions, or build it into your DOM Ready extension in order to create a custom payload rather than just passing utag.data

How to inhibit/block utag.view automatic call in an extension only on certain conditions?

Moderator
Moderator

@meghashri OOOOOooooo... I'd accept that as a solution! #hinthint #winkwink

If you liked it then you should have put a kudo on it!
Public