Wednesday, March 27, 2013

When a bounce isn't a bounce - and what to do about it

One thing we've noticed recently is that Google Analytics could be better at measuring bounces. From the Google Analytics page at https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide they're defining a bounce as "a session containing only one interaction hit". But here's the thing - that could mean a lady who clicks your ad, reads your landing page for 3 minutes, scrolls up and down while reading, calls your phone number (included on the page) then closes her laptop and leaves Starbucks. Do you really think she's a bounce? We don't.

So what's the solution? We've come up with some clever JavaScript code that'll change this. By adding this code to your landing pages, any visitor who spends at least 5 seconds reading your page is no longer considered a bounce. (If you prefer 8 seconds, just replace 5 with 8 in the code below):



<!-- Start of AdReturns code -->
<script type="text/javascript">
(function(t){
  var i;
  if(!window.onscroll) window.onscroll=function(e){
    if(i) window.clearTimeout(i); i=window.setTimeout(function(){send('Scroll')},2000);
  };
  function send(x){if(window._gaq) _gaq.push(['_trackEvent','Engagement',x,window.location.href])}
  function ping(t){window.setTimeout(function(){send('Ping'); ping(parseInt(t*1.5))},t)}
  ping(t*1000);
})(5); // After 5 seconds, they're not a bounce
</script>
<!-- End of AdReturns code -->


What does this do? Well it uses Google Analytics Event Tracking to send 2 kinds of events to Google Analytics. First, after 5 seconds it sends a "ping" event to say the visitor hasn't clicked the back button and is not a bounce (then again after 10 seconds, etc). Plus, if the visitor scrolls down the page and reads for at least 2 seconds, it sends a "scroll" event to say they're not a bounce. These 2 types of engagement provide really valuable information - they show up as "Engagement" events in your Google Analytics reports.

By adding this code to your landing pages, you'll begin to receive way more accurate data about your bounces, plus a more accurate measure of the time people spend reading your website (because each ping event tells Google Analytics how long they've been there).

We really hope you like this small innovation to improve your Google Analytics data quality.

The Kevins at AdReturns.com

PS To stop the ping events when the page tab is hidden in the browser, use this enhanced version of the code https://adreturns.com/analytics.js

PPS We've updated this code to work with Google's new Universal Analytics