how to skip an extension on link tracking

Gold Contributor
Gold Contributor
When we fire utag.link the all-tag extensions and specific tag extensions are executed again. How can we avoid that? Is it right to enclosure the extension within a condition like the following? if(utag.data.link_type === undefined){ ... }
2 REPLIES 2

how to skip an extension on link tracking

Employee Emeritus
If you are using a JS Code extension, there is a variable called 'a' which contains the event type. It has the value of either "view" or "link" matching to utag.view() and utag.link() calls. You can suppress the extension from firing by adding this at the top of the extension: {code:js} // only fire on view events if (a !== "view") { return; } {code}

how to skip an extension on link tracking

Employee Emeritus

Hey Jarno,

 

There are a couple methods for this:

 

  1. Make sure the extensions are scoped to the correct tags. Extensions scoped to specific tags will only run when the tag is loaded based on the Load Rules. This is a clean and easy way to ensure that extensions only run when they are supposed to.
  2. If the extension must be scoped to All Tags then conditions should be used to keep the extension from firing. Either update the condition in the tag to be specific and exclude the link events, or in JS Code extensions add a condition similar to your example.

 

I would suggest adding an extension that looks like the following screenshot. This extension will output a variable called, "_utag_event." This variable will equal either "view" or "link." Then you can use this as the identifier in your conditions: Set Data Values Extension: if _utag_event equals "view" //JS Code Extension Condition if(b._utag_event=="view"){ // do something here }

Public