]> git.parisson.com Git - django-google-tools.git/commitdiff
Fixed async template JS to use a proper closure
authorChris Adams <chris@improbable.org>
Sun, 18 Jul 2010 21:47:49 +0000 (05:47 +0800)
committerClint Ecker <clint@arstechnica.com>
Mon, 19 Jul 2010 15:27:24 +0000 (23:27 +0800)
google_analytics/templates/google_analytics/analytics_async_template.html

index f92b7b1529956273a10f3f7528ee463d1471115d..08a2b996f5e2965e61226ef0555aadb494609f96 100644 (file)
@@ -1,13 +1,15 @@
 <script type="text/javascript">
-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');
- // Avoid problems if the document doesn't actually contain a HEAD element:
- var container = document.getElementsByTagName("head")[0] || document.body;
- container.appendChild(ga); 
+    var _gaq = _gaq || [];
+    _gaq.push(['_setAccount', '{{ analytics_code }}']);
+    _gaq.push(['_trackPageview']);
+
+    var ga=document.createElement('script');
+    ga.src=('https:'==document.location.protocol ? 
+        'https://ssl' : 'http://www')+'.google-analytics.com/ga.js';
+    ga.setAttribute('async','true');
+    // Avoid problems if the document doesn't actually contain a HEAD element:
+    var container = document.getElementsByTagName("head")[0] || document.body;
+    container.appendChild(ga);
+})();
 </script>