Occasional Contributor
Posts: 57
Registered: ‎12-11-2015

Creating event types beyond utag.view and

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){
    console.log("Creating utag." + event_name + "() event");
    this[event_name] = function (a,c,d){
      return this.track({

So if wasn't already something that exists, you could create it thus:





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.

Community Manager
Posts: 868
Registered: ‎08-26-2015

Re: Creating event types beyond utag.view and

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.
0 Kudos
Posts: 138
Registered: ‎11-15-2015

Re: Creating event types beyond utag.view and

Hello @UnknownJ,

Excellent post and its really useful!!!
0 Kudos