You may have noticed that the Google Analytics team have been very busy over the past few weeks, pushing out updates to all accounts. The latest addition is to the Site Speed area, where you can see a collection of page loading times on a per user basis rather than en masse.
So how is this different from before? Well, the old way that data was collected was via a random sampling of 10% of your site’s visitors. As in, Analytics would measure the page loading time of 1 in 10 visitors to your site for each page. So essentially, what could happen was that visitor A who is on a shared 56k modem connection was timed for your homepage, and a uni student on their University’s 100mb+ connection was measured for Page B.
This obviously creates a bit of an imbalance in terms of the data that is reported, but this new update seems to be about picking one user and timing all their visits until they leave the site. If this is what it seems to be, then it represents a massive step forward in terms of getting consistent accurate data throughout Analytics.
Unfortunately, Google’s current documentation on how to implement this tracking is sorely lacking on its help page, which can be viewed here. (EDIT: The implementation documentation has since been added.)
So I’ll show you here how to build your own. The following example tracks how long it takes our Jquery Library to load from our Google CDN.
_gaq.push([‘_trackTiming’ < – This tells Analytics to add a time to our reports.
,’jQuery’, < – This tells Analytics we want to call this time Jquery.
,’Load Library’, < – Here we can give a more specific label , which I’m choosing to call this the ‘Load Library’.
,20, < – The time you’re adding to the reports (Note: you have to calculate this yourself).
,’Google CDN’, < – Optional: Lets you segment and label even further (so we know this particular one is from the Google CDN)
,50]); < – Optional: The sample rate. Here I’ve chosen 50% of visitors to be timed.
When you put all this together you get something that looks like this.
_gaq.push([‘_trackTiming’, ‘jQuery’, ‘Load Library’, 20, ‘Google CDN’, 50]);
And you’ll be collecting time (and improving your conversions) in no time! Any questions? Drop them in the comments below.