A small library to interact with Kissmetrics that can be shared across a client (browser) and server (Node.js).
In place of a more detailed readme, the annotated source is very thorough.
Install from NPM with:
npm install kissmetrics-js
In Node.js, you probably just want to require the module.
KM = require'kissmetrics-js';km = API_KEY username;// ...
Record data about a logged in user.
// General activitykm = API_KEY username;kmrecord'Published post';kmsetlast_seen: ;// Change usernamekmrecord'Change username';kmaliasusername;
Record data about a logged out user.
// New visitorkm = API_KEY;kmrecord'Visited front page';kmrecord'Visited signup form';// Signs upkmrecord'Signed up';kmaliasusername;// Record more data as the new logged in userkm = API_KEY username;kmrecord'Publish post';
Automatically-generated ID's are deleted from storage by default when
alias() is called, but you have the option to save them by passing a second argument of
km = API_KEY;kmrecord'Signed up'aliasusername;console.logkm_storageget;// nullkm = API_KEY;kmrecord'Signed up'aliasusername false;console.logkm_storageget;// "56a44b65ddad8a4ab00885ec42e7d2f7db46dcd69c3f"
Data methods can be chained.
km = API_KEY;kmrecord'Visited front page'record'Visited signup form'record'Signed up'aliasusernamerecord'Published post';
alias() updates the instance's
person attribute, so future data is recorded using the new identity.
km = API_KEY 'evan';console.logkmperson;// evankmalias'evansolomon';console.logkmperson;// evansolomonkmrecord'foobar';// Recorded as "evansolomon" doing "foobar"