Last active
August 29, 2015 14:03
-
-
Save miguelmota/cf1fcaba14f3bf50efa1 to your computer and use it in GitHub Desktop.
Google Analytics in Angular.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('App') | |
.controller('MyController', function ($scope, $location, $window, $rootScope) { | |
$rootScope.$on('$routeChangeSuccess', function(e) { | |
$window.ga('send', 'pageview', { page: $location.path() }); | |
}); | |
$scope.gaEvent = function() { | |
$window.ga('send', { | |
'hitType': 'event', | |
'eventCategory': 'button', | |
'eventAction': 'click', | |
'eventLabel': 'Navbar', | |
'eventValue': 'About' | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment