1

Possible Duplicate:
How do I dynamically load Google Analytics JavaScript?

Hi Google Analytics call is slowing down my web page load. Is there a way to initiate call to Google Analytics only after the complete web page has been rendered?

Community
  • 1
  • 1
Pykih
  • 2,769
  • 3
  • 29
  • 38
  • 3
    Previously asked here: http://stackoverflow.com/questions/753514/how-do-i-dynamically-load-google-analytics-javascript – Benjie Oct 27 '11 at 15:01

3 Answers3

0

Generally the new analytics js code has a setting to load asynchronously(after the page has loaded that is). Something like

ga.setAttribute('async', 'true');

I also think you can get the asynchronous code from the "tracking code" of the analytics panel if you choose to display the advanced options but i'm not sure about that. :)

cyph3r
  • 373
  • 5
  • 13
0

What about Asynchronous Tracking? It shouldn't affect page load…

rodneyrehm
  • 13,442
  • 1
  • 40
  • 56
0

Asynchronous GA snippet, extracted from HTML5 Boilerplate:

var _gaq=[["_setAccount","UA-XXXXX-X"],["_trackPageview"]]; // Change UA-XXXXX-X to be your site's ID 
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
Lapple
  • 3,385
  • 20
  • 20