Google Analytics quite recently added a new feature for checking your site speed and page loading time, awesome isn’t it? It is not an automatic upgrade, so you need to tweak your Google Analytics default tracking code to enable this feature. Now it will be easy to improve your site’s loading speed.
Add Site Speed Code in Google Analytics
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 this [sample code] :
<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>
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>
This will be really useful for webmasters and bloggers to detect which landing pages are slow. Also you can find the cause and fix it earlier since Google considers site loading speed as a key factor in SERPs.
Pradeep, thanks for taking the time to break this down. I just upgraded servers so I am definitely gonna install this code. Hopefully my site checks out.
I think the line "_gaq.push(['_trackPageLoadTime']);" is added to the code by default. I checked my source code and it's already there. Maybe I updated the code once upon a time !
While updating the code, I realized I was using the old analytics code. Updated to the new one and also added the above mentioned line of code. Thanks Pradeep. π
Thank you so much Pradeep for given here π And, this is one of the best directions to increase your web site loading speed π Great code π
Site speed is the newest member in the SERP requirements. Will give it a shot for sure. Thanks.
Thanks Pradeep, till know i was checking it through Google Webmaster tool, will now integrate This Code !
Great Tip, I shall defiantly be using this one.
nice feature by google. added the code let check how efficient the feature is. btw thanks for share.
Thanks for this.I didn't know about this.I've added this code.I'm going to check how fast my site loads.