Have you noticed that when it comes to duration related statistics, Google Analytics has two? One is Average Time on Site and the other is Average Time on Page. If you’re interested in learning the difference, keep reading.
Like learning to play a new board game, this is one of those things that’s best illustrated via example. Let’s pretend someone visits our website at 3:00pm. At 3:02 they click on a link that sends them to a second page on our site. At 3:06 they go to a third page. At some point after that they exit our website. We know that they were on the site from 3:00 to 3:06, but in general, we don’t know how long the user was on that last page.
Why is this? Every time a new page is requested (in this case at 3:00, 3:02, and 3:06), a request timestamp is sent to Google Analytics. This timestamp sets a clock that lets us get more information about the visit length. When a visitor leaves the website though, there generally isn’t any kind of request that tells Google Analytics how long the visitor was on that last page.
As a result, Google Analytics records the Visit Duration for this user from the time of the first timestamp request to the time of the last timestamp request. In this case it would be 6 minutes, from 3:00 to 3:06. Notice here that the duration of the last pageview is completely omitted from the calculation. That’s because we don’t have a request and therefore don’t have a sense of the length of the last pageview.
Average Time on Page is calculated based on the average length of time between each page request. In this case it would be 3 minutes, aka the average of 2 minutes (3:00 to 3:02), and 4 minutes (3:02 to 3:06).
Where this gets complicated is with bounces. If someone visits a site and exits out without visiting another page (regardless of the amount of time they spend on that page), that lack of a second timestamp request results in 0:00 time on site. This number is included in the overall statistics for Average Time on Site, but does not affect the Average Time on Page.
This explains why Average Visit Duration (which includes 0:00 bounces in the calculation) is typically lower than Time on Page (which only calculates instances where a person visits multiple pages).
Exceptions & Complications
There are, of course, exceptions to the aforementioned. The first thing that can affect these numbers is tabbed browsing. Different analytics tools handle multiple open tabs differently, so that’s something to consider.
Perhaps more important, Goals affect the Time on Site metric. If a visitor completes a goal prior to leaving your website, Google detects that the user is still on the site, thereby extending the time on site number past that final page load.
A Hack
If you’re a stickler for time on site, there are hacks you can create to increase the accuracy of your metrics. The most common one is to add a piece of JavaScript to your site that detects when the visitor exits your website. In the technical world, this is called onbeforeunload, and the code looks like this:
window.onbeforeunload = storeData;
function storeData(){
_gaq.push(['_trackEvent', 'Visitor Info', 'Scrolling', 'Up', 200, true]);
}