@circulare/usage-tracker-browser
This library is a wraper of mixpanel-browser
This library currently does not support group
tracking and some functions from the people
context.
Getting Started
This library is available as a package on NPM named @circulare/usage-tracker-browser
(not to be confused with the node version). To install into a project using NPM with a front-end packager such as Browserify or Webpack:
npm install --save @circulare/usage-tracker-browser
You can then require the lib like a standard Node.js module:
Usage
The token passed to .init() is the project token on your Mixpanel account. More information on how to locate the project token can be found here.
import mixpanel from '@circulare/usage-tracker-browser';
mixpanel.init('MIXPANEL_TOKEN', options);
mixpanel.track('An event');
API Reference
-
init(mixpanel_token[, options]) – Loads the token used to identify the mixpanel project and sets some configurations
- mixpanel_token - Mixpanel project token
- options
- debug:boolean
- track_pageview:boolean
- persistence:string
- For more options see the mixpanel docs
-
track(channelName[, properties]) – tracks an event
- channelName:string - Name of the event to track
- properties:object - Any
key:value
pair to add to the tracking info.
-
track_pageview(properties) – The
track_pageview
option currently does not auto-track page views in single-page applications. For single-page applications or other manual page view tracking, Mixpanel offers the standard page view event throughmixpanel.track_pageview()
. This call can be inserted into any hooks or listeners for your framework of choice.- properties:object - The standard page view event includes the page title, URL components, and marketing parameters described below. Additional page view event properties can also be added as event properties.