How to track page speed with Google Analytics

The time it takes a page to load all requests and render the content is called “page speed”. We’ve known for over a year that…

The time it takes a page to load all requests and render the content is called “page speed”. We’ve known for over a year that page speed is a small part of Google’s ranking algorithm and affects AdWords Landing Page Quality but until now the only way to track it was using 3rd party tools and storing the data manually, in an excel spreadsheet or otherwise.

Google Analytics Page Speed Tracking

During May this year, Google announced the new page speed tracking tool within Google Analytics. The implementation of one line of code within the analytics tracking script allows webmasters to analyse:

  • Visitors: Page load times for different visitors in geographic locations.
  • Traffic sources: Different campaign load times
  • Content: How quickly pages load.
  • Technology: Which browsers load content more quickly.

These analyses will allow you to improve the user experience of your website. However, the tool does not give users reasons why the page is the speed it is. Google provide a Chrome extensions for this: Page Speed for Chrome – a click of a button gives the user advice on how to make the page load quicker.

How to implement the tracking code

Implementation is incredibly easy, it is just one line:

push(['_trackPageLoadTime']);

You need to include this within the analytics tracking site that should be placed within the <head></head> section, so your tracking code should look like this:

<script type="text/javascript">
  var _gaq = _gaq || [];
  push(['_setAccount', 'UA-000000-0']);
  push(['_trackPageview']);
  push(['_trackPageLoadTime']);
  (function() {
    var ga = createelement('script'); type = 'text/javascript'; async = true;
    src = ('https:' == protocol ? 'https://ssl' : 'http://www') + 'google-analytics/js';
    var s = getelementsbytagname('script')[0]; insertbefore(ga, s);
  })();
</script>

Jason John MillsWritten by Jason John Mills