Setup Google Analytics to Measure Page Load Time, Site Speed

Google Analytics introduced a new feature which allows webmasters to measure Page Load Time and Site Speed and get detailed analytics reports for your site.

However, it is not an automatic upgrade, and webmasters, bloggers and site owners need to edit code of the Google Analytics code to start tracking page load time and get the site analytics reports. Though available in2 different scripts, it is advisable to always use the asynchronous script as it will not delay page loading and track more pageviews. Remember to place it in HEAD section of your page html.

Add Site Speed Analytics Code

To get the new site speed report, add the following line to your analytics code
_gaq.push(['_trackPageLoadTime']);

Now this is how your code will look like

<script type="text/javascript">
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-XXXXX-X']);
 _gaq.push(['_trackPageview']);
 _gaq.push(['_trackPageLoadTime']);
 (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
 })();
</script>

Remember the page speed measurement is turned off by default and unless you make this code change to the Analytics tracking code, this report will not be generated. It will help you find which landing pages are slowest, find the causes and fix up your site speed issue as it is a search engine ranking criteria.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.