Current time: 07-15-2020, 01:57 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Google analytics - lazy load
03-05-2012, 11:54 AM
Post: #3
RE: Google analytics - lazy load
fwiw I have now set the Google analytics to this:-


var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_trackPageview']);

($(window).load( 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);
}));

The difference from the std Google code is ($(window).load( function() { and an extra closing rounded bracket on the last line.

It all loads after page load, it appears to be worth about 0.1 seconds to my site.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Google analytics - lazy load - doc_uk - 02-24-2012, 12:11 PM
RE: Google analytics - lazy load - pmeenan - 02-25-2012, 01:45 AM
RE: Google analytics - lazy load - doc_uk - 03-05-2012 11:54 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)