In our previous post, we discussed the high bounce rate that, by default, you can expect to see for your blog. In today’s post, we review a way to customize the Google Analytics Tracking Code (GATC) so the bounce rate for your blog – or for any primarily single-page website – represents user activity more accurately.
Here is what’s happening with the customized GATC below:
- The GATC generates a regular pageview when the page loads.
- Using setTimeout and _trackEvent, we’re setting an event to execute 15 seconds after page load. (The “15000″ parameter represents milliseconds and equates to 15 seconds.)
- If the visitor stays on the page for 15 seconds, the event fires, and Google Analytics no longer considers this visit to be a bounce.
var _gaq = _gaq || ;
setTimeout("_gaq.push(['_trackEvent', 'adjusted-bounce', 'read','15-seconds'])",15000);
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script'); s.parentNode.insertBefore(ga, s);
If possible, it would be slightly preferable to call setTimeout within the GATC on
the home page only, but there is not much harm if it’s included on every page of your blog, since the event is significant mostly for Bounce Rate calculations and not in itself.
Thanks to the official Google Analytics blog for introducing this technique for adjusted bounce rate. (Unless your own blog is very heavily trafficked, I wouldn’t be overly concerned about the caveat at the end of that blog post.)