Fast Google Analytics setup for Rails.
Add the following to your Gemfile:
gem 'google-analytics-rails'
Then run:
bundle install
http://rubydoc.info/github/bgarret/google-analytics-rails
config/environments/production.rb:
# replace this with your tracker code
GA.tracker = "UA-xxxxxx-x"
app/views/layout/application.html.erb, in the <head> tag :
<%= analytics_init if Rails.env.production? %>
config/environments/production.rb:
# replace this with your production tracker code
GAR.tracker = "UA-xxxxxx-x"
config/environments/development.rb:
# replace this with your development tracker code
GAR.tracker = "UA-xxxxxx-x"
app/views/layout/application.html.erb, in the <head> tag :
<%= analytics_init :local => Rails.env.development? %>
google-analytics-rails is released under the MIT license: