Fast Universal Google Analytics setup for Rails. This gem is mostly intended for small to medium websites with a simple analytics strategy.
First, sign up for a google analytics account:
Add the following to your Gemfile
:
gem 'google-analytics-rails', '1.1.0'
Then run:
bundle install
config/environments/production.rb
:
# replace this with your tracker code
GA.tracker = "UA-112233-4"
app/views/layout/application.html.erb
, in the <head>
tag :
<%= analytics_init if GoogleAnalytics.valid_tracker? %>
Different configurations also available for:
Many developers have reported problems with page view tracking both with and without Turbolinks
Resources with detail on potential fixes: