Google Universal Analytics - Adjusted Bounce Rate Script implementation

Silver Contributor
Silver Contributor

hi all,

 

I was wondering if you guys give me a tip on how I could implement a small addition to the Google Universal Analytics tag in order to trigger an event for users who has a dwell time of min 30 seconds?

 

Normally I would just augment the GA script with the below:

  setTimeout("_gaq.push(['_trackEvent', '30_seconds', 'read'])",30000); 

 

but given the turnkey integration this is not available.

 

Should I tweak the tag template in this case?

 

thank you for your thoughts in advance,

 

Ben

3 REPLIES 3

Google Universal Analytics - Adjusted Bounce Rate Script implementation

Moderator
Moderator

Hi Ben,

 

There are a couple of options here. First of all, I found an updated article that discusses adjusted bounce rate with Universal Analytics:

 

http://urlprofiler.com/blog/adjusted-bounce-rate/

 

For the benefit of others reading this post, the idea is to just fire any GA event after a defined amount of time (often 30 seconds), to prevent GA from counting a user as having "bounced" if they do not view any further pages on your site, but have spent time reading the initial page.

 

Technically, the solution is to use a JavaScript "setTimeout" to fire a GA custom event, with a timeout of 30000ms, so that if the user is still on the page after that time, GA will not count it as a bounce (note that this event should be "interactive", which is the default anyway. Non-interaction events will have no effect on bounce rate).

 

The 2 options you have in Tealium are:

 

1) Use the native GA code to trigger the event (Not recommended):

 

In an extension scoped to the GA tag (scope is actually not very important here, but this scope gives the best chance that GA will be ready when the event is fired), enter the following code:

 

 

// arguments => command: send, event type: event, event category, event action
setTimeout("ga('send','event','adjusted bounce rate','page visit 30 seconds or more')",30000);

NOTE: In Tealium's GUA tag, we auto-generate tracker names unless you have manually specified one. If you just have a single GA tag/UA property on your page, Tealium's auto-generated tracker name will be 'tealium_0'. To incorporate this into the Adjusted Bounce Rate snippet, you would do the following:

 

// arguments => command: send, event type: event, event category, event action
setTimeout("ga('tealium_0.send','event','adjusted bounce rate','page visit 30 seconds or more')",30000);

Each subsequent tracker will be incremented by 1, e.g. tealium_1, tealium_2 etc. If you have your own custom tracker name, substitute tealium_0 for this in the above code. Note that you will need to run this snippet for each individual tracker on the page, so 3 times if you have 3 GA trackers.

 

2) Use Tealium's utag.link API call to trigger the event (Recommended).

 

This method achieves exactly the same as the first one, but the Tealium GA template takes care of assigning the event to each tracker on your behalf, so you do not need to know the tracker name.

 

Again, in an extension scoped to the GA tag, enter the following code:

 

// adjust last parameter if you wish to change to a different timeout value, e.g. 10000 for 10 seconds
setTimeout(utag.link({
  "ga_eventCategory" : "adjusted bounce rate", 
  "ga_eventAction" : "page visit 30 seconds or more"
},
null, // this is a placeholder for a callback function. Not required in this case, so null is fine.
['23'] // this is the UID of the GA tag in your Tealium profile. This ensures that only the GA tag will be executed.
),30000);

This code assumes that you have 2 TIQ data sources: ga_eventCategory and ga_eventAction. If you have different data sources for event category and event action, change this code accordingly to reflect your own data source names. It also assumes that these data sources are mapped in your GA tag to eventCategory and eventAction respectively.

 

Please note that the values used for event catgory and action have no bearing on the final result; you can use whatever values to like here. The purpose is just to let GA know that something happened on the page, and it doesn't care what label is assigned to the event.

 

I hope this is useful. I am going to investigate the feasibility of adding this functionality in the next release of the GA template, as I think it is potentially useful to others too. Right now, and extension is the recommended way to implement this, as described above. We never recommend editing the template code unless there is an exceptionally good reason to do so, as it makes it much more difficult for you to upgrade the template in future.

 

 

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.

Google Universal Analytics - Adjusted Bounce Rate Script implementation

Silver Contributor
Silver Contributor

thanks very much Craig, all makes sense.

 

the only thing I needed to tweak was the UID of the tag as it is is 30 rather than 23.

Tag name: UK GUA profile

 

 

 

 

cheers,


Ben

 

Google Universal Analytics - Adjusted Bounce Rate Script implementation

Silver Contributor
Silver Contributor

hey @craig_rouse,

 

It seems that after rolling this out, the GA is called multiple times, often up to 80 times which puts a strain on page time load.

 

I've noticed that our configured event is the culprit with each call containing the same parameters, except for the cache buster and the hit sequence parameter "_s="

 

Just to give you a sample:

 

  1. v:
    1
  2. _v:
    j43
  3. a:
    1269062538
  4. t:
    event
  5. _s:
    12
  6. dl:
    (deleted by Ben)
  7. ul:
    en-gb
  8. de:
    UTF-8
  9. dt:
    (Deleted by Ben)
  10. sd:
    24-bit
  11. sr:
    1920x1080
  12. vp:
    1903x239
  13. je:
    0
  14. fl:
    22.0 r0
  15. ec:
    adjusted bounce rate
  16. ea:
    page visit 30 seconds or more
  17. _u:
    QCEAgAAB~
  18. jid:
     
  19. cid:
    469314237.1456331352
  20. tid:
    UA-6430175-3
  21. z:
    1899277491

 

Would you have any ideas why this would be the case?

These calls are being made upon page load, they don't even seem to take 30 seconds..

 

cheers,


Ben

 

Public