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, Angular, Backbone, Ember and other front-end JavaScript frameworks.
Why analytics from ostr.io?:
- 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);
- Referrers.
Installation
Go to Analytics section and select domain name for which you would like install visitors metrics. Go to "Show integration guide" and pick trackingId
(17 symbols):
1<script async defer type="text/javascript" src="https://analytics.ostr.io/Asy4kHJndi84KKlpq.js"></script> 2<!-- trackingId is: Asy4kHJndi84KKlpq -->
Installation options:
- Include suggested
script
tag intohead
of your HTML page - The simplest way; - Include code from this repository into main website's script file;
- Install via NPM/Atmosphere.
Meteor
meteor add ostrio:analytics
NPM:
npm install ostrio-analytics --save
Usage
Constructor new OstrioTrackerClass(trackingId)
trackingId
{String} - [Required] Website identifier. To obtaintrackingId
see "Installation" section above
Meteor:
1Meteor.startup(function() { 2 this.OstrioTracker = new OstrioTrackerClass('trackingId'); 3});
Browser:
1var OstrioTracker = new OstrioTrackerClass('trackingId');
RequireJS (+AMD Module):
1var Analytics = require('ostrio-analytics'); 2var OstrioTracker = new 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.
OstrioTracker.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 symbolsvalue
{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.
OstrioTracker.track()
Use to manually send tracking info. This method has no arguments.
Other examples
Deep router integration:
1var OstrioTracker = new OstrioTrackerClass('trackingId', false); 2/*!pesudo code!*/ 3router({ 4 '/': function() { 5 OstrioTracker.track(); 6 }, 7 8 '/two': function() { 9 OstrioTracker.track(); 10 }, 11 12 '/three': function() { 13 OstrioTracker.track(); 14 } 15});
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.
1var OstrioTracker = new OstrioTrackerClass('trackingId', false); 2 3History.Adapter.bind(window, 'statechange', function(){ 4 OstrioTracker.track(); 5});