Skip to content

Angular module for Segment, the Analytics API and customer data hub.

License

Notifications You must be signed in to change notification settings

glints-dev/angular-segment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-segment

An AngularJS module for Segment, the Analytics API and customer data hub.

This module automatically includes Segment's Analytics.js library, you do not need to include it yourself.

Installing

At the moment, the name angular-segment has been taken up by another project.

So you need to include this project via Git:

bower install --save https://github.com/glints-dev/angular-segment#master

Example

Inject SegmentProvider into your .config() block, then configure as follows:

SegmentProvider.setWriteKey('<your write key>');

Then in everywhere else, you just need to inject Segment.

angular.module('myApp')
  .controller('AwesomeController', function (Segment) {
    Segment.track('Signed Up', {
      plan: 'Startup',
      source: 'Analytics Academy'
    });
  });

If you use ui-router and would like to track virtual page views, you can simply do:

$rootScope.on('$stateChangeSuccess', function () {
  Segment.page();
});

Directives

There is currently one directive to simply tracking.

<button type="submit"
        data-segment-track="Signed Up"
        data-segment-track-options="{
          plan: 'Startup',
          source: 'Analytics Academy'
        }">
</button>

About

Angular module for Segment, the Analytics API and customer data hub.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published