Adding google anayltics tracking

This commit is contained in:
Colin McLeod
2015-05-04 22:14:01 -07:00
parent bf04a2cc19
commit 748e1261fe
3 changed files with 19 additions and 2 deletions

View File

@@ -1,11 +1,16 @@
angular.module('app', ['ui.router', 'shipyard', 'ngLodash', 'app.templates'])
.run(['$rootScope','$document','$state','commonArray','shipPurpose','shipSize','hardPointClass','internalGroupMap','hardpointsGroupMap', function ($rootScope, $doc, $state, CArr, shipPurpose, sz, hpc, igMap, hgMap) {
.run(['$rootScope', '$location', '$window', '$document','$state','commonArray','shipPurpose','shipSize','hardPointClass','internalGroupMap','hardpointsGroupMap', function ($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hpc, igMap, hgMap) {
// Redirect any state transition errors to the error controller/state
$rootScope.$on('$stateChangeError', function(e, toState, toParams, fromState, fromParams, error){
e.preventDefault();
$state.go('error', error, {location:false, reload:true}); // Go to error state, reload the controller, keep the current URL
});
// Track on Google analytics if available
$rootScope.$on('$stateChangeSuccess', function() {
if ($window.ga) ga('send', 'pageview', {page: $location.path()});
});
// Global Reference variables
$rootScope.CArr = CArr;
$rootScope.SP = shipPurpose;