Skip to content
gyarra edited this page Feb 1, 2013 · 17 revisions

Using KissMetrics with Analytical

Here's how to use Analytical with KissMetrics

Setup

To configure Kissmetrics, add the following to analytical.yml

production:
  kiss_metrics:
    js_url_key: '//doug1izaerwt3.cloudfront.net/<your identifier>.js'

Note that entering your key doesn't seem to be required, just your personalized URL to the JS library.

Common Methods

Record

analytical.event('event_name', {'property_name':'value'}) # hash is optional

instead of

_kmq.push(['record', 'event_name', {'property_name':'value'}]); 

Set

analytical.set({'property_name':'value'})

instead of

_kmq.push(['set', {'property_name':'value'}]);

Identify

Identify takes an optional user_id as the first arg because other libraries use the ID. If you only care about KissMetrics the ID may be omitted.

analytical.identify(current_user.id, :email=>current_user.email) # user_id is optional
analytical.identify(current_user.email)

instead of

_kmq.push(['identify', 'email']);

Alias

analytical.alias_identify(first_id, second_id)

instead of

_kmq.push(['alias', 'first_id', 'second_id']);

Javascript Methods

TrackSubmit

TrackSubmit isn't part of the Analytical API, however using a server side Analytical record is better than trackSubmit for performance anyway.

analytical.event('event_name', params[:FORM_MODEL_NAME])

instead of

_kmq.push(['trackSubmit', ELEMENT_ID_OR_CLASS, EVENT_NAME]);