Creating event types beyond utag.view and utag.link

Tealium Expert
Tealium Expert

The following code will allow you to very quickly create additional event types if created as a DOM Ready extension, without the need to edit templates etc.:

 

window.utag.createEvent = function(event_name){
  if(!this[event_name]){
    console.log("Creating utag." + event_name + "() event");
    this[event_name] = function (a,c,d){
      return this.track({
        event:event_name,
        data:a,
        cfg:{
          cb:c,
          uids:d
        }
      })
    };
  }
};


So if utag.link() wasn't already something that exists, you could create it thus:

 

 

utag.createEvent("link");

 

Some event types that you may want to consider:

  • view
    Fires when the page loads (this already exists)
  • link
    Fires on generic on-page interactions
  • seen
    Fires when the page is first made visible (i.e. tags won't fire if a new tab is opened in the background until focus switches to that tab)
  • visit
    Fires once per session and then uses a cookie with a 30 minute expiry (whose timings are reset on every page) to suppress future events (take care combining this with load rules, if your load rules aren't met on the first event in the session, the tag won't fire in that session)
  • defer
    Fires after the page has completely finished loading, for any tags that don't need to execute immediately and might otherwise slow down the overall page load time.
  • return
    Fires after the page has been inactive for 30 minutes and is then reactivated. Essentially treats a reactivated dormant tab as a new pageview for any tags scoped to that event type

Specific use cases and code examples available for anyone interested.. The "seen" and "return" event types are useful for analytics tags that need to better capture the customer experience, whereas "visit" and "defer" make it easier for marketing tags to reduce the number of calls they make, particularly during initial page load.

2 REPLIES 2

Creating event types beyond utag.view and utag.link

Employee Emeritus

OMG @UnknownJ. Brilliant as always. Thank you for this!

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.

Creating event types beyond utag.view and utag.link

Gold Contributor
Gold Contributor
Hello @UnknownJ,

Excellent post and its really useful!!!
Public