Sha256: 12a6f6771fa1945703bca58cb8a23f4a2f49352d61469c371143e63b8d4ddaa9

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

module Analytics
  module Rails
    module ActionView
      module Base

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

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
analytics-rails-0.1.0 lib/analytics/rails/action_view/base.rb
analytics-rails-0.0.8 lib/analytics/rails/action_view/base.rb