Skip to content
πŸ“Š Visitor's analytics tracking code for service
Branch: master
Clone or download
Latest commit 8f85cca Aug 19, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Package meta update Mar 31, 2018
.eslintrc 🧹 Clean up Feb 2, 2019
.gitignore Ignore .DS_Store Apr 26, 2019
.npmignore Simplify package structure Aug 18, 2019
.versions v1.2.9 Atmosphere Aug 19, 2019 v1.0.3 May 6, 2016 Package meta update Mar 31, 2018 Package meta update Mar 31, 2018 v1.0.3 May 6, 2016
LICENSE Year bump Jan 12, 2019 v1.2.9 Atmosphere Aug 19, 2019
package.js v1.2.9 Atmosphere Aug 19, 2019
package.json v1.1.9 NPM Aug 19, 2019

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

Why analytics?:

  • πŸ‘ Open Source tracking code;
  • πŸš€ Lightweight, less than 2.4KB;
  • 😎 No DOM changes;
  • 😎 No heavy CPU tasks;
  • 😎 No extra scripts loading;
  • 🀝 Support for History API (HTML5 History Management);
  • 🀝 Support most of JavaScript front-end based frameworks and routings;
  • πŸ“ˆπŸš€ Fast, all metrics are available in real-time;
  • ⚑️ Track Accelerated Mobile Pages (AMP);
  • πŸ›‘βœ‹ Detect and Track AdBlock usage;
  • πŸ” Transparent data collection;
  • 😎 Respect DNT policy;
  • πŸ‘¨β€βš–οΈ Follows latest GDPR recommendations;
  • πŸ™† Easy opt-out procedure for end-users;
  • 🐞 Global Runtime Errors tracking - Whenever an error happens during runtime you will be reported to "Errors" 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;
  • Sessions;
  • Unique users;
  • Pageviews:
    • Page title;
    • Page URL.
  • Demographics:
    • Country;
    • City.
  • System:
    • Mobile devices;
    • Browsers;
    • Operating System.
  • Behavior:
    • Custom events (see below);
    • Referrers.
  • Global Scripts Errors and Exceptions:
    • Catch all JS-runtime errors and exceptions;
    • Browser name and release;
    • Operating System name and release;
    • Device name and version;
    • Script name and line number where the error occurred.


Installation options:

  • Include suggested script tag into head of your HTML page - The simplest way;
  • Include code from this repository into main website' 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 to install visitors metrics. To find "Tracking ID" click on "Show integration guide" and pick {{trackingId}} (17 symbols).

Script tag:

<script async defer type="text/javascript" src="{{trackingId}}.js"></script>


meteor add ostrio:analytics

Meteor via NPM:

meteor npm install ostrio-analytics --save


npm install ostrio-analytics --save


Constructor new Analytics(trackingId [, auto])

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

Script Tag:

// After including script-tag
// analytics automatically executes in 'auto' mode,
// its instance is available in global scope as `OstrioTracker`
// Example: OstrioTracker.pushEvent(foo, bar);


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

Meteor via NPM:

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

NPM (CommonJS/RequireJS/Module):

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

Using minifed version:

// After adding minified analytics code to your project
// In global scope as `OstrioTrackerClass` and `OTC`
// as a short (short name was used in initial release,
// we keep it for compatibility reasons)

// Example:
const analyticsTracker = new OstrioTrackerClass('trackingId');
// Example 2:
const analyticsTracker = new window.OstrioTrackerClass('trackingId');
// Example 3:
const analyticsTracker = new OTC('trackingId');
// Example 4:
const analyticsTracker = new window.OTC('trackingId');
// Example 5: Initiate class with disabled "auto" tracking
// With disabled "auto" tracking you need to use
// `.track()` method to track a "visit"
const analyticsTracker = new window.OTC('trackingId', false);
whenUserVisit(() => {

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

.pushEvent(key, value) method

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

  • key {String} - [Required] The length of the event key must be between 1 and 24 symbols;
  • value {String} - [Required] The length of the event value must be between 1 and 64 symbols.

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


// Various examples on tracking custom user's actions
analyticsTracker.pushEvent('userAction', 'login');
analyticsTracker.pushEvent('userAction', 'logout');
analyticsTracker.pushEvent('userAction', 'signup');

analyticsTracker.pushEvent('click', 'purchase');
analyticsTracker.pushEvent('click', 'purchase-left');
analyticsTracker.pushEvent('click', 'pricing - more info');
<script type="text/javascript">
  // make analyticsTracker global variable
  window.analyticsTracker = analyticsTracker;

  <h2>Buy Now</h2>
    <option disabled>Select product</option>
  <input name="qty" />
  <!-- Example on tracking form submit -->
  <button type="submit" onClick="analyticsTracker.pushEvent('checkout', 'buy-now-form')">Checkout</button>

In a similar way using .pushEvent you can detect and track AdBlock usage and Accelerated Mobile Pages (AMP).

.track() method

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


const Analytics = require('ostrio-analytics');
const analyticsTracker = new Analytics('trackingId', false);

// jQuery or any other similar case:
$(document).ready(() => {

Other examples

Deep router integration:

const Analytics = require('ostrio-analytics');
const analyticsTracker = new Analytics('trackingId', false);

/*!pseudo code!*/
  '/'() {
  '/two'() {
  '/three'() {

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.

const Analytics = require('ostrio-analytics');
const analyticsTracker = new Analytics('trackingId', false);

History.Adapter.bind(window, 'statechange', () => {

Opt-out for end-users

As our analytics solution fully respects DNT signals, to opt-out end-users need to activate DNT signals in a browser. To find out how to enable DNT and read more about "Do Not Track", visit - All About DNT homepage.

You can’t perform that action at this time.