Solving “Avg. Session Duration” 00:00:00 Google Analytics

vicnumb Sep 23, 2014

Sep 23 2014 Published by under Misc

I am running a one page web service Looking through google analytics noticed recently that
Avg. Session Duration 00:00:00

Google Analytics Average 00:00:00

Google Analytics Average 00:00:00

My question was “Is my service that bad?”

After some looking around, I’ve found a solution.

Google Session Duration is a average time between landing on your website and moving to another page on your website.

My site is a one page web service. There are no additional pages for users to move through.

To make google analytics take into consideration session time, I had to add exit tracking code.
When users move away from my word counter web service, the exit tracking code is run and session time stamp is saved for google stats.

jQuery Tracking Code on Exit Solution

<script src="//"></script>
$(window).on('beforeunload', function() {
    _gaq.push(['_trackPageview', '/bounce']);

JavaScript Tracking Code on Exit Solution

window.onbeforeunload = function (e) {
  e = e || window.event;
  //IE and Firefox code
  if (e) {
    _gaq.push(['_trackPageview', '/bounce']);
  //Safari & Chrome code
  return _gaq.push(['_trackPageview', '/bounce']);

Hope this helps.

No responses yet

Leave a Reply