Skip to content

Instantly share code, notes, and snippets.

@bwll
Last active December 27, 2015 06:14
Show Gist options
  • Save bwll/d9c5362e69a7a6b914c0 to your computer and use it in GitHub Desktop.
Save bwll/d9c5362e69a7a6b914c0 to your computer and use it in GitHub Desktop.
Firing in Optimizely page view goal in AngularJS
/*
Send an Optimizely page view tracking call in AngularJS
*/
window.scope = window.angular.element(document).find('body').scope();
window.scope.$on('$locationChangeSuccess', function(event, next, current) {
window['optimizely'] = window['optimizely'] || [];
window.optimizely.push(['trackEvent', next]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment