Google analytics, Rails 3.1

To use google analytics on rails 3.1

Add

group :production do
  gem 'rack-google_analytics', :require => "rack/google_analytics"
end

to your Gemfile

Run

bundle install

Add

if Rails.env == "production"
  config.middleware.use("Rack::GoogleAnalytics", :web_property_id => "UA-[yourcodehere]-1")
end

to your config/application.rb

 

Post new comment

  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options