renaud.io

Yet Another Command Line Experiments.

Add Google Analytics to Enki blog (i.e. a rails 3 application)

Permalink

This blog is powered by Enki and I’d like to monitor the (absence of?) frequentation. As a rails 3 application, integrating Google Analytics is dead simple thanks to the rack-google_analytics ruby gem and the associated documentation

Just add the following to your Gemfile:

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

and this configuration entry to your config/environments/production.rb:

1
2
# Configure Rack::GoogleAnalytics
config.middleware.use("Rack::GoogleAnalytics", :web_property_id => "UA-12345678-1")

with the web_property_id provided by Analytics.

I told you: dead simple!

Comments