0.0
No commit activity in last 3 years
No release in over 3 years
BigBro provides view helpers to generate Analytics code (with the noscript counterpart), test helpers to assert your page contains the tracking code and a configuration method to set your GA account from environment.rb
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.3.8
 Project Readme

BigBro: A Google Analytics plugin for Rails

Installation

Via RubyGems:

gem install panmind-bigbro

Or via Rails Plugin:

script/plugin install git://github.com/Panmind/bigbro.git

Usage

After the plugin has been loaded, you'll have an analytics helper to use in your views. It generates an optimized version of the Google Analytics code, and a <noscript> tag containing the direct path to the __utm.gif image, to track JS-disabled browsers as well.

The analytics helper tracks the current page load by default, you can disable this behaviour by passing the :track => false option.

Configuration

You must set your analytics account via the Panmind::BigBro.set() method in your config/environment.rb:

Panmind::BigBro.set(:account => 'UA-12345-67')

In production mode, the .set() method will raise an ArgumentError if no account is provided, unless the :disabled option is set to true.

We use these switches to allow the developer to run the application in production mode on localhost while not sending requests to Analytics.

We know that the ga.js is empty if the Referer is localhost, but on Panmind there are situations in which the referer is reset, thus a complete disable is necessary

In development mode the plugin is always disabled.

Testing

A simple assert_analytics() helper is included in to aid verifying that the layouts include the analytics helper. Its usage is super simple:

class FooControllerTest < ActionController::TestCase
  context "An user" do
    should "be tracked by analytics" do
      get :index
      assert_analytics
    end
  end
end

Compatibility

Tested with Rails 2.3.8 with the rails_xss plugin installed, running under Ruby 1.9.1-p378.