Skip to content

Instantly share code, notes, and snippets.

@acreeger
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acreeger/53b005fa8ad26bcbed8f to your computer and use it in GitHub Desktop.
Save acreeger/53b005fa8ad26bcbed8f to your computer and use it in GitHub Desktop.
/**
* @license Angulartics v0.17.0
* (c) 2013 Luis Farzati http://luisfarzati.github.io/angulartics
* License: MIT
*/
(function(angular) {
'use strict';
/**
* @ngdoc overview
* @name angulartics.segment.io
* Enables analytics support for Segment.io (http://segment.io)
*/
angular.module('angulartics.segment.io', ['angulartics'])
.config(['$analyticsProvider','$injector', function ($analyticsProvider, $injector) {
$analyticsProvider.registerPageTrack(function (path) {
$injector.invoke(['$location',function($location) {
try {
analytics.page({
path: path,
url: $location.absUrl()
});
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
}]);
});
$analyticsProvider.registerEventTrack(function (action, properties) {
try {
analytics.track(action, properties);
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
});
}]);
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment