Skip to content

izavits/node.analytics

Repository files navigation

node.analytics

Build Status npm License PRs Welcome Semver

A library to integrate analytics to nodejs applications

This is a wrapper library for popular analytics providers. It abstracts over their methods and offers an API to easily identify users and track events in nodejs applications.

Table of Contents

Install

Via npm:

npm install --save analytica

API

The module exports methods to:

  • require the core analytics lib
  • require the provided integrations
  • add the desired integration
  • initialize the library
  • track event

Example usage:

Require the core analytics library and the mixpanel integration:

var analytics = require('analytica').core;
var mp = require('analytica').mixpanelIntegration;
analytics.addIntegration(mp);
var options = {token: "<YOUR_TOKEN>"};
analytics.initialize({'Mixpanel': options});

Identify user and track event:

analytics.identify(123, { name: 'testuser', email: 'testemail@test.com', '$distinct_id': 123 },
  function () {
    console.log('done identifying user');
  });

analytics.track('my event', { distinct_id: 123, descr: 'test event' },
  function () {
    console.log('done tracking event');
  });

Tests

Run the test suite by doing:

npm test

Support

If you're having any problem, please raise an issue on GitHub

Contributing

See the contributing file!

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

The project is licensed under the Apache 2.0 license.

About

A library to integrate analytics to nodejs applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published