Skip to content

Instantly share code, notes, and snippets.

@dannycroft
Created October 16, 2014 16:02
Show Gist options
  • Save dannycroft/b9a168e0387dffb63cce to your computer and use it in GitHub Desktop.
Save dannycroft/b9a168e0387dffb63cce to your computer and use it in GitHub Desktop.
Angular GA
(function(angular) {
angular.module('analytics', ['ng']).service('analytics', [
'$rootScope', '$window', '$location', function($rootScope, $window, $location) {
var track = function() {
$window._gaq.push(['_trackPageview', $location.path()]);
};
$rootScope.$on('$viewContentLoaded', track);
}
]);
}(window.angular));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment