An Ember-CLI addon that eases integration between your application and Mixpanel. This is a close port of rahim's ember-segmentio.
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.
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'
}
Once included your router will automatically send a page view event to Mixpanel everytime the URL changes.
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.
TBD
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
Simple ember-cli addon just follow the documentation :)