Skip to content
Browse files

update google analytics script

  • Loading branch information...
1 parent dc6eb12 commit 7ba11f3bcdca27f93cf715549e4a06ac983cbf91 @sbounmy committed Mar 13, 2012
Showing with 9 additions and 8 deletions.
  1. +9 −8 core/app/views/spree/shared/_google_analytics.html.erb
View
17 core/app/views/spree/shared/_google_analytics.html.erb
@@ -1,15 +1,16 @@
<% if tracker = Spree::Tracker.current %>
<%= javascript_tag do -%>
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- <% end -%>
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '<%= tracker.analytics_id -%>']);
+ _gaq.push(['_trackPageview']);
- <%= javascript_tag do -%>
- var pageTracker = _gat._getTracker("<%= tracker.analytics_id %>");
- pageTracker._initData();
- pageTracker._trackPageview();
- <% end -%>
+ (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);
+ })();
+ <% end -%>
<% if flash[:commerce_tracking] %>

0 comments on commit 7ba11f3

Please sign in to comment.
Something went wrong with that request. Please try again.