If you are familiar with how web analytics tools measure time spent on page or site, you know that time spent on the last page is (usually) counted as 0 seconds. With other words, time on last page is not measured.
The reason this isn't measured is simply that the web analytics tool need to have a start point and a end point. On the last page of the visitors visit, there isn't a end point normally to calculate time against.
To be able to get time spent on last page you have to be able measure 2 things:
- Clicks on Back Button
- Visitors leaving by Closing their Browser or Browser Tab
In this article I show you how you can measure "True" Time spent on your website with Google Analytics by measuring Back Button and Visitors who leave by Closing their Browser.
The time difference between Standard Time Measurment and True Time Measurement can be huge.
How to measure "True" Time by Tracking Back Button and users who leave by Closing their Browser
There are 3 steps you have to do to be able to do this tracking.
Step 1.
The first thing you should do is to create a new Google Analytics profile with a new profile ID. You shouldn't implement this measurement in your regular Google Analytics profile. This method will "kill" your Bounce Rate in addition to that your time spent reports of course will be inflated. With other words, we are going to track data to 2 different profiles in Google Analytics.
The principle for tracking to 2 different profiles is shown below using Google Analytics Asynchronous code.
- <!-- Google Analytics code for Tracking to 2 profiles -->
- <script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(
- ['_setAccount', 'UA-XXXXX-1'], //Main Google Analytics profile
- ['_trackPageview'],
- ['pageTrackerTime._setAccount', 'UA-XXXXX-2'], //Profile for True Time Tracking
- ['pageTrackerTime._trackPageview']
- );
- </script>
- <script type="text/javascript">
- (function() {
- var ga = document.createElement('script');
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- ga.setAttribute('async', 'true');
- document.documentElement.firstChild.appendChild(ga);
- })();
- </script>
Step 2.
The next thing you have to do is to download this ZIP-file. The ZIP-file contains 2 files and is necessary in the measurement of the Back Button.
- Blank.html - This is an empty HTML-file that you must upload to the root of your domain (yourdomain.com/blank.html).
- Backfix.js - This is the javascript that does all the magic that is necessary to be able to track the Back Button
The solution I'm using to track the Back Button is a slightly modified solution borrowed from the Browser Back Button Detection article by Brook Bryan. The original solution was creating 404-errors that Google Analytics counted, so the only thing I have done is to fix that.
Upload backfix.js to for example a folder called script.
Step 3.
This is the last step. Copy and paste the code below between <head> and </head> on your website.
- <!-- Google Analytics script - Track Closing Browser -->
- <script type="text/javascript">
- leaveSiteStart = new Date;
- function leftSite() {
- var leaveSiteEnd = (new Date - leaveSiteStart )/1000;
- var roundleaveSiteEnd = Math.round(leaveSiteEnd,1);
- _gaq.push(['pageTrackerTime._trackEvent','Track Time','Closed Browser', document.location.href, roundleaveSiteEnd]);
- }
- window.onbeforeunload=leftSite;
- </script>
- <!-- Google Analytics script - Track Back Button -->
- <script type="text/javascript" src="/script/backfix.js"></script>
- <script script type="text/javascript">
- bajb_backdetect.OnBack = function() {
- var leaveSiteEnd2 = (new Date - leaveSiteStart )/1000;
- var roundleaveSiteEnd2 = Math.round(leaveSiteEnd2,1);
- _gaq.push(['pageTrackerTime._trackEvent','Track Time','Back Button', document.location.href, roundleaveSiteEnd2]);
- }
- </script>
If you have done everything correctly, you should if you drill down to you Event Tracking Report find a report called Track Time. There you will find a report similar to the screenshot below.
Event Labels in that report will be the URL the visitor was on before he either clicked the back button or closed the browser. Event Value reported is the number of seconds from the visitor arrived to the page and until the browser was closed or the back button was clicked.
If you drill down even more in your numbers you will perhaps get the same feeling as me:
Time spent on page or site isn't the same as time spent interaction with your content.
To be honest, I think the image below sums up the behavior to many of my visitors. They do hopefully not fell asleep, but they leave the page open and do some other things before they close the page.
Image may be NSFW.
Clik here to view.
Some readers may spend long time on your website due to other reasons than reading. Image by notemily.
Things to be aware of - and Why did I do this?
First, I'm not a programmer so if you find any errors or don't like mye code, please tell it nicely.
This measurement method also shows why this method isn't a standard method in web analytics tools - this method isn't accurate. Only around 80 % of my visitors are measured using this method, which is why I have written "True" Time and not True Time in this blog post.
Since I'm normally a person that will speak out for actionable analytics, which this isn't, so why did I do this?
An important part of web analytics is to be curious. If you aren't curious you will find it more difficult to be friend with your data. With other word, the reason for me to do this was simply because I was curious and had some geek time to use.
Some final words
If you look around on my site you have probably noticed that everything else is written in Norwegian. Since this blog normally is in Norwegian, and I haven't had time to implement a multilingual blog system, you find some explanations of how to comment below:
Click "Legg til kommentar" below. Than fill out your name (Navn) (Mandatory), e-mail (Epost) (Mandatory) and your website (Ditt nettsted) if you have a website. HTML formatting doesn't work in my comment field, use BBCode formatting instead. You can drag the comment field around if you want to. If you want to preview what you have written, click on "Forhåndsvis". When you are done and want to save your comment, click on "Lagre". If you haven't had any comments approved on this blog before, I will have to approve your comment manually.
Related articles
- Tracking Content Scrollers, Scanners & Readers in Google Analytics
- How to Identify if Visitors are Reading Your Articles with Google Analytics
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.