Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created January 19, 2016 07:38
Show Gist options
  • Save rheajt/2d2d199dff4a72e18be5 to your computer and use it in GitHub Desktop.
Save rheajt/2d2d199dff4a72e18be5 to your computer and use it in GitHub Desktop.
google analytics with angularjs
/* Comment out the last line of the analytics code that is given by Google.
* This code triggers on page views in angular
*/
app.run(['$rootScope', '$location', '$window', function($rootScope, $location, $window) {
$rootScope.$on('$routeChangeSuccess', function() {
$window.ga('send', 'pageview', {page: $location.url()});
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment