Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created November 28, 2014 15:12
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 kanakiyajay/7865540b72f9eda31517 to your computer and use it in GitHub Desktop.
Save kanakiyajay/7865540b72f9eda31517 to your computer and use it in GitHub Desktop.
Tracking Google Analytics in Angular js Apps
MyApp.run(function($rootScope, $location, $routeParams, $window){
$rootScope.$on('$routeChangeSuccess', function() {
var output=$location.path()+"?";
angular.forEach($routeParams,function(value,key){
output+=key+"="+value+"&";
})
output=output.substr(0,output.length-1);
$window._gaq.push(['_trackPageView', output]);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment