Snowplow Ruby Tracker 0.1.0 released

23 April 2014  •  Fred Blundun

We are happy to announce the release of the new Snowplow Ruby Tracker. This is a Ruby gem designed to send Snowplow events to a Snowplow collector from a Ruby or Rails environment. This post will cover installing and setting up the Tracker, and provide some basic information about its features:

  1. How to install the tracker
  2. How to use the tracker
  3. Features
  4. Getting help

The Snowplow Ruby Tracker is published to RubyGems, the Ruby community’s gem hosting service. This makes it easy to install the Tracker locally, or add it as a dependency into your own Ruby app.

To install the Tracker locally:

$ gem install snowplow-tracker

To add the Snowplow Ruby Tracker as a dependency to your own Ruby gem, edit your gemfile and add:

gem 'snowplow-tracker'

The Snowplow Ruby Tracker is compatible with Ruby versions 1.9.3, 2.0.0, and 2.1.0. The setup page has more information on the Tracker’s own dependencies.

Require the Snowplow Tracker like this:

require 'snowplow-tracker'

Initialize a Tracker like this:

tracker = SnowplowTracker::Tracker.new('d3rkrsqld9gmqf.cloudfront.net', 'cf', '')

Set some additional information:

tracker.set_user_id('a73e94')
tracker.set_platform('mob')
tracker.set_lang('en')

And fire some events:

tracker.track_page_view("www.example.com", "example page", "www.referrer.com")

tracker.track_struct_event("shop", "add-to-basket", None, "pcs", 2, 1369330909)

tracker.track_ecommerce_transaction({
  'order_id' => '12345',
  'total_value' => 35,
  'affiliation' => 'my_company',
  'tax_value' => 0,
  'shipping' => 0,
  'city' => 'Phoenix',
  'state' => 'Arizona',
  'country' => 'USA',
  'currency' => 'GBP'
  },
  [ {
  'sku' => 'pbz0026',
  'price' => 20,
  'quantity' => 1
  },
  {
  'sku' => 'pbz0038',
  'price' => 15,
  'quantity' => 1,
  'name' => 'crystals',
  'category' => 'magic'
  } ])

For in-depth usage information on the Snowplow Ruby Tracker, see the wiki page.

The functionality and architecture of the Snowplow Ruby Tracker is very similar to that of the Snowplow Python Tracker. It has support for the same Snowplow events, and custom contexts can be attached to every event.

The contracts library for Ruby provides type checking. We have written a test suite using RSpec and webmock.

Since this is the first release of the Ruby Tracker, we’re keen to hear people’s opinions. If you have an idea for a new feature or want help getting things set up, please get in touch. And raise an issue if you spot any bugs!