Google Analytics ‘rubaidh’ plugin with multiple account support

For the Bonnes-Ondes project, we want to allow users to follow their listener visits. The solution is simple : associate a Google Analytics tracker id to the Bonnes-Ondes host … but the Google Analytics ‘rubaidh’ plugin supports only a single Google Analytics account.

A recent patch allows to override the Google Anaytics tracker id, but we wanted to use several tracker ids in our case.

A small patch later and the Bonnes-Ondes controller can associate a Google Analytics account to the request. The after filter generates google code for several accounts. This plugin fork uses a GoogleAnalytics instance for each account and concats the code of each found instance.


A default account can be specified as previously but with an instance :

Rubaidh::GoogleAnalytics.default_account =
   Rubaidh::GoogleAnalytics.new('UA-1896598-5')

In the controller, a Google Analytics account can be associated to the request :

request.google_analytics_account =
   Rubaidh::GoogleAnalytics.new(user_tracker_id)

When several accounts are specified, the generated code contains several google tracker codes.

The plugin is already in production. You see the resulted pages in the Radio Esperanzah! web site.

The code of this Google Analytics plugin fork with multiple account support is available into the Bonnes Ondes repository.

Tags: , , , ,

One Response to “Google Analytics ‘rubaidh’ plugin with multiple account support”

  1. Alban’s blog » Blog Archive » GitHub repository for Google Analytics with multiple accounts plugin Says:

    [...] forked the rubaidh’s plugin and applied the current patch created this summer for [...]

Leave a Reply