Irus Analytics
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 7 commits ahead of uohull:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


IrusAnalytics is a gem that provides a simple way to send analytics to the IRUS-UK repository aggregation service.

More information about IRUS-UK can be found at In summary the IRUS-UK service is designed to provide article-level usage statistics for Institutional Repositories. To sign up and use IRUS-UK, please see the above link.

This gem was developed for use with a Hydra repository, but it can be used with any other web application supporting Ruby gems.

Build Status

Build Status


Add this line to your application's Gemfile:

gem 'irus_analytics'

And then execute:

$ bundle

Or install it yourself as:

$ gem install irus_analytics


Once you have the gem, run the following generator:

$ rails g irus_analytics:config

This will generate editable configuration and translation files in the config folder.


This uses a similar mechanism to the standard rails database.yml file to allow for per-environment configuration of the values for:

is used to configure the name of the source respository url (i.e. what the url for your repository)

is used to define the IRUS-UK server endpoint, this can be configured for the test version of the service.

is used to specify the name of the file containing the robot UserAgents as regular expressions.


The IrusAnalytics code is designed to be called after a download event has happened in your application. The following code added to the Rails controller handles the content download.

A simple example...

class YourDownloadController < ApplicationController
  # You need to include the IrusAnalytics behaviour module
  include IrusAnalytics::Controller::AnalyticsBehaviour 

  after_filter :send_analytics, only: [:show]

  def show
    @id = params[:id] 
    # Your code


  #  You need to define this method for IrusAnalytics to use as the identifier (typically a OAI valid identifier)
  def item_identifier 

Therefore in summary...

include IrusAnalytics::Controller::AnalyticsBehaviour  

after_filter :send_analytics, only: [:show]

def item_identifier

... needs adding to the relevant controller.

To be compliant with the IRUS-UK client requirements/recommendations this Gem makes use of the Resque Resque provides a simple way to create background jobs within your Ruby application, and is specifically used within this gem to push the analytics posts onto a queue. This means the download functionality within your application is unaffected by the send analytics call, and it provides a means of queuing analytics if the IRUS-UK server is down.

Note: Resque requires Redis to be installed

By installing this gem, your application should have access to the Resque rake tasks. These can be seen by running "rake -T", the list should include:-

rake resque:failures:sort 
rake resque:work
rake resque:workers

To start the resque background job for this gem use

QUEUE=irus_analytics rake environment resque:work


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request