Sha256: 528eb1f690b89609c3e59b3548485d340cb20528754bc9841fec862b46f36a33

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

module Analytics
  module Rails
    module Helpers

      def google_analytics_include_tag(account)
        if ::Rails.env.production?
          script = <<-SCRIPT
            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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
analytics-rails-0.0.2 lib/analytics/rails/helpers.rb