An Ember plugin that eases integration between your application and Segment.io. This is a close port of ryanto's ember-google-analytics.
You should include ember-segmentio.js after your main Ember import.
You will also need to include the snippit that Segment.io provide, following their instructions.
Once included your router will automatically send a page view event to Segment.io everytime the URL changes.
You can track custom events with this plugin. If you have a controller
action that you wish to track you can use the
Ember.SegmentioMixin
like so:
App.VideoController = Ember.Controller.extend(
Ember.SegmentioMixin, {
actions: {
play: function() {
// ...
// this.trackEvent(event, properties, options, callback)
this.trackEvent('Play video');
// or
this.trackEvent('Play video', {
title: 'Never gonna give you up'
}, {
integrations: {
'All': false,
'Mixpanel': true,
'KISSMetrics': true
}
});
}
}
});
trackEvent
has an identical method signature to Segment.io's analytics.track
, see their docs for details. (In short: event is mandatory, everything else optional)
The mixin can be applied to any Ember object.
These two Segment.io methods are also available on the mixin, wrapping directly to the Segment.io counterparts with identical method signatures.
To enable console logging any events or page views sent to Segment.io:
window.ENV = window.ENV || {};
window.ENV.LOG_EVENT_TRACKING = true;
This plugin is built with rake pipeline, which requires Ruby. To get started:
bundle install
bundle exec rackup
Edit code and visit http://localhost:9292 to run tests.