lib/caboodle/kits/analytics/analytics.rb in caboodle-0.2.14 vs lib/caboodle/kits/analytics/analytics.rb in caboodle-0.2.15
- old
+ new
@@ -1,21 +1,23 @@
-module Caboodle
- class Analytics < Caboodle::Kit
- description "Adds Google Analytics to every page of the site"
- required [:analytics_id]
- end
-end
+class Caboodle::Analytics < Caboodle::Kit
+
+ description "Adds Google Analytics to every page of the site"
+
+ required [:analytics_id]
+
+ if ENV["RACK_ENV"] == "production"
+ add_layout :after_body, "<script type=\"text/javascript\">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '#{Caboodle::Site.analytics_id}']);
+ _gaq.push(['_setDomainName', 'none']);
+ _gaq.push(['_setAllowLinker', true]);
+ _gaq.push(['_trackPageview']);
-Caboodle::Layout.add_to_layout "after_body" => "<script type=\"text/javascript\">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', '#{Caboodle::Site.analytics_id}']);
- _gaq.push(['_setDomainName', 'none']);
- _gaq.push(['_setAllowLinker', true]);
- _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);
+ })();
- (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);
- })();
-
-</script>"
\ No newline at end of file
+ </script>"
+ end
+end