v1.2.1Published 7 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Analytics for ostr.io

Ostr.io provides lightweight and full-featured visitor's analytics for websites. Our solution fully compatible and works "out-of-box" with Meteor, React, Angular, Backbone, Ember and other front-end JavaScript frameworks.

Why ostr.io analytics?:

  • Open Source tracking code;
  • Transparent data collection;
  • Support for History API (HTML5 History Management);
  • Support most JavaScript font-end based frameworks and routings;
  • Respect DNT policy;
  • Lightweight, less than 2.5KB;
  • No DOM changes;
  • No heavy CPU tasks;
  • No extra scripts loading;
  • Fast, all data available in real time;
  • Global runtime Errors tracking - Whenever error happens during runtime you will be reported into Events section. This is super-useful as you never can test your client's code in all imaginable environments, but your website visitors do.

Analytics includes:

  • Real-time users;
  • Pageviews;
  • Sessions;
  • Unique users;
  • Demographics:
    • Country;
    • City.
  • System:
    • Mobile devices;
    • Browsers;
    • Operating System.
  • Behavior:
    • Custom events (see below);
    • Global Scripts Errors and Exceptions;
    • Referrers.


Installation options:

  • Include suggested script tag into head of your HTML page - The simplest way;
  • Include code from this repository into main website's script file;
  • Install via NPM;
  • Install via Atmosphere (Meteor).

To find installation instruction - go to Analytics section and select domain name for which you would like install visitors metrics. To find "trackingId" click on "Show integration guide" and pick trackingId (17 symbols).

Script tag:

1<script async defer type="text/javascript" src="https://analytics.ostr.io/trackingId.js"></script>


meteor add ostrio:analytics

Meteor via NPM:

meteor npm install ostrio-analytics --save


npm install ostrio-analytics --save


Constructor new OstrioTrackerClass(trackingId [, auto])

  • trackingId {String} - [Required] Website identifier. To obtain trackingId see "Installation" section above;
  • auto - {Boolean} - [Optional] Default - true. If set to false all visit and actions have to be tracked with .track() method, see below.


1import Analytics from 'meteor/ostrio:analytics';
2analyticsTracker = new Analytics('trackingId');

Meteor via NPM:

1analyticsTracker = new (require('ostrio-analytics'))('trackingId');

NPM (CommonJS/RequireJS/Module):

1const analyticsTracker = new (require('ostrio-analytics'))('trackingId');

From this point you're good to go. All visitor's actions will be collected by ostr.io analytics. For custom events - see below.

analyticsTracker.pushEvent(key, value)

Custom events is useful for tracking certain activity on your website, like clicks, form submits and others user's behaviors.

  • key {String} - [Required] Length of event key must be between 1 and 24 symbols
  • value {String} - [Required] Length of event value must be between 1 and 64 symbols

If length of key or value is higher than limits, it will be truncated without throwing exception.


Use to manually send tracking info. This method has no arguments.

Other examples

Deep router integration:
1const Analytics = require('ostrio-analytics');
2const analyticsTracker = new Analytics('trackingId', false);
4/*!pesudo code!*/
6  '/'() {
7    analyticsTracker.track();
8  },
10  '/two'() {
11    analyticsTracker.track();
12  },
14  '/three'() {
15    analyticsTracker.track();
16  }
Deep History.js Integration

Although History.js and History API supported "out-of-box", you may want to optimize tracking behavior to meet your needs.

1const Analytics = require('ostrio-analytics');
2const analyticsTracker = new Analytics('trackingId', false);
4History.Adapter.bind(window, 'statechange', function(){
5  analyticsTracker.track();