Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

rahim/ember-segmentio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ember Segment.io

An Ember plugin that eases integration between your application and Segment.io. This is a close port of ryanto's ember-google-analytics.

Usage

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.

Tracking Page Views

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

Tracking Additional Events

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.

identifyUser, aliasUser

These two Segment.io methods are also available on the mixin, wrapping directly to the Segment.io counterparts with identical method signatures.

Logging

To enable console logging any events or page views sent to Segment.io:

window.ENV = window.ENV || {};
window.ENV.LOG_EVENT_TRACKING = true;

Development

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published