Module: Analytics::Rails::ActionView::Base

Defined in:
lib/analytics/rails/action_view/base.rb

Instance Method Summary collapse

Instance Method Details

#google_analytics_include_tag(account) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/analytics/rails/action_view/base.rb', line 6

def google_analytics_include_tag()
  if ::Rails.env.production?
    script = <<-SCRIPT
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', '#{}']);
      _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);
      })();
    SCRIPT
    (:script, script.html_safe, :type => 'text/javascript')
  end
end