Skip to content
Browse files

Add a Google Analytics partial.

  • Loading branch information...
1 parent 4b15957 commit 402e85a93136e34d4cd8953310f5a623bab198ba @vanderhoorn vanderhoorn committed May 15, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 app/views/shared/_google_analytics.html.haml
View
12 app/views/shared/_google_analytics.html.haml
@@ -0,0 +1,12 @@
+- if current_site.content.analytics_code.present? || Settler[:google_analytics_key].present?
+ / Google Analytics code
+ :javascript
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '#{escape_javascript(current_site.content.analytics_code || Settler[:google_analytics_key])}']);
+ _gaq.push(['_trackPageview']);
+
+ (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);
+ })();

0 comments on commit 402e85a

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