No commit activity in last 3 years
No release in over 3 years
FlowmorAnalytics makes it easy to include google, clicky, etc. analytic scripts into your application and they will only render in production (unless you override)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3

Runtime

~> 4.1
 Project Readme

FlowmorAnalytics

FlowmorAnalytics injects google, clicky, etc. analytic scripts into your application.

I got tired of wiring up Google and Clicky Analytics to my Rails 4.x apps and just wanted to be able add the site keys to a config/analytics.yml file and require statement to the application.js file and be done. Oh, and I wanted it to be smart enough to only render the scripts when in production.

Developed and tested against Rails 4.1

Installation

Add to your Gemfile

gem 'flowmor_analytics'

Then bundle install

Run the generator to get initial config/analytics.yml file:

rails g flowmor_analytics:install

Edit config/analytics.yml to add your site_id keys:

#
# Only production renders the tracking scripts by default
#
development:
  google:
    site_id: "UA-XXXXX"
  clicky:
    site_id: 123456789

test:
  google:
    site_id: "UA-XXXXX"
  clicky:
    site_id: 123456789

production:
  google:
    site_id: "UA-XXXXX"
  clicky:
    site_id: 123456789

If you need to render when not in production (or turn off in production), set :render in the yml file:

# If you want to render for an environment, then add "render: true" either at the environment
# section or at the site-specific section.
#
# Environment Example:
#   development:
#     render: true
#     google:
#       site_id: ...
#
#
# Site Example:
#   development:
#     google:
#       render: true
#       site_id: ...
#     clicky:
#       render: false
#       site_id: ...
#

TODO

  • Ensure it plays well with turbolinks (I don't use turbolinks, but I know turbolinks leads to inaccurate analytics)