From: Chris Adams Date: Wed, 2 Dec 2009 13:56:24 +0000 (-0500) Subject: Switch to Asynchronous Tracking X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ff09c682ba1d4199df4273ae43e2f44197448f15;p=django-google-tools.git Switch to Asynchronous Tracking This avoids a common GA performance hit: http://googlecode.blogspot.com/2009/12/google-analytics-launches-asynchronous.html --- diff --git a/google_analytics/templates/google_analytics/analytics_template.html b/google_analytics/templates/google_analytics/analytics_template.html index 4335675..4bf6b69 100644 --- a/google_analytics/templates/google_analytics/analytics_template.html +++ b/google_analytics/templates/google_analytics/analytics_template.html @@ -1,10 +1,12 @@ - +var _gaq = _gaq || []; +_gaq.push(['_setAccount', '{{ analytics_code }}']); +_gaq.push(['_trackPageview']); +(function() { +var ga = document.createElement('script'); +ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; +ga.setAttribute('async', 'true'); +document.documentElement.firstChild.appendChild(ga); +})(); + \ No newline at end of file