Ruby Library

Our Ruby Library has the basic functionality laid out in our API specifications. It allows you to record events, set properties and alias users. However, you might miss these features from our JavaScript library:

For these reasons we recommend our JavaScript Library to our users, even if you are running Ruby on Rails, and to use the Ruby Library for recording events that occur server-side (account Upgrades may be an example of one such event). You might also consider looking at other APIs our customers have created.

Setup

You can download a copy of the API from

http://github.com/kissmetrics/km

You will need your API key which you can find in your site settings.

Usage

Before calling any of the common methods you must call KM.init with a valid API key:

KM.init(string KM_KEY [, options])

The available options are:

Example:

KM.init("this is your key", :log_dir => '/var/logs/kissmetrics/')

Example Calls

KM.identify('bob@bob.com')
KM.record('Viewed Homepage')
KM.record('Signed Up', {'Plan' => 'Pro', 'Amount' => 99.95})
KM.record('Signed Up', {'_d' => 1, '_t' => 1234567890})
KM.set({:gender=>'male', 'Plan Name' => 'Pro'})
KM.alias('bob', 'bob@bob.com')

Troubleshooting

If you were watching for the events in KISSmetrics Live and did not see them, it helps to review what our library logged. In the log directory, you may see these files:

If you contact support to troubleshoot, please refer to the contents of these files, if possible.


Contributed by Eric Fung

comments powered by Disqus