Skip to content

ToddSmithSalter/ember-cli-mixpanel

 
 

Repository files navigation

Ember CLI addon for Mixpanel

An Ember-CLI addon that eases integration between your application and Mixpanel. This is a close port of rahim's ember-segmentio.

Usage

Add ember-cli-mixpanel as a dependency to your package.json or just run ember install:addon ember-cli-mixpanel.

There is one manual step, which includes our wrapper in your Router. Just extend your Router with tracking_mixin.js.

This addon includes the required Mixpanel script automatically, so no extra effort needed here.

Configuration

There are some options available to configure the mixpanel addon. Only token is a mandatory option otherwise

mixpanel: {
  enabled: false,
  LOG_EVENT_TRACKING: false,
  token: 'b619c413e0d49a362236388a4f5ec679'
}

Tracking Page Views

Once included your router will automatically send a page view event to Mixpanel everytime the URL changes.

Tracking Additional Events

You can track addinional events as well. Let's say we would like to track play events on our controller.

import Ember from 'ember'
import TrackingMixin from './mixin/tracking_mixin'

var VideoController = Ember.Controller.extend(
  TrackingMixin, {

  actions: {
    play: function() {
      // ...
      // this.trackEvent(event, properties, options, callback)
      this.trackEvent('Play video');
      // or
      this.trackEvent('Play video', {
        title: 'Never gonna give you up'
      }
    });
  }
});

The mixin can be applied to any Ember object.

identifyUser, aliasUser

TBD

Logging

For debugging purposes you can enable logging for all events. Events are still send to Mixpanel but you will get an additional output in your console.

Add LOG_EVENT_TRACKING = true|false to your config file

Development

Simple ember-cli addon just follow the documentation :)

About

Ember CLI addon for tracking users activities via Mixpanel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 78.4%
  • HTML 20.7%
  • Other 0.9%