reactor.am

JavaScript client library for Reactor.am API


Keywords
reactor, reactor.am, segmentation, analytics
License
MIT
Install
npm install reactor.am@0.1.0

Documentation

Reactor.am is the most important from marketing automation, CRM and user analytics, in one easy to use service.

This is a JavaScript client library for Reactor.am API.

Install

$ npm install reactor.am --save

Basic usage

You can use Reactor server side with Node/io.js or client side with Browserify/Webpack.

var Reactor = require('reactor.am');

var reactor = new Reactor({
  applicationId: 'YOUR_APPLICATION_ID' // required
});

reactor.collect({
  user_id: '661787707', // required
  session: 1405587905,
  first_name_s: 'John',
  last_name_s: 'Doe',
  gender_g: 'male',
  share_facebook_b: false
});

reactor.event('purchase', {
  user_id: '661787707', // required
  price_f: 10.30
});

Make sure you provide required fields, Reactor will throw otherwise.

Requests are batched by default. If you want to use it in the browser, you'd probably want to turn this off.

var reactor = new Reactor({
  applicationId: 'YOUR_APPLICATION_ID',
  batchRequests: false
});

There are more options available that you can set, check documentation.

Documentation

Reactor constructor takes follwing options:

applicationId: string // required
batchRequests: boolean // defaults to true
batchSize: number // defaults to 30
flushTimeout: number // defaults to 10000
baseUrl: string // defaults to https://api.reactor.am/collector

Available methods:

collect(data: object, callback: function)
event(eventType: string, data: object, callback: function)
flush(callback: function) // all callbacks are optional

Full documentation can be found at docs.reactor.am

Debugging

Reactor uses debug, set env variable DEBUG (Node) or localStorage.debug (browser) to reactor.am* (logs everything) or reactor.am:requests (logs only requests).