Skip to content

Commit

Permalink
#9 Analytics at page change
Browse files Browse the repository at this point in the history
  • Loading branch information
simison committed Dec 24, 2014
1 parent b89ae26 commit 7bfbd4f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions public/modules/core/controllers/header.client.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

/* This declares to JSHint that 'ga' is a global variable: */
/*global ga:false */

angular.module('core').controller('HeaderController', ['$scope', '$log', '$filter', '$geolocation', 'Authentication', 'Menus', 'Socket',
function($scope, $log, $filter, $geolocation, Authentication, Menus, Socket) {

Expand All @@ -22,11 +25,23 @@ angular.module('core').controller('HeaderController', ['$scope', '$log', '$filte
$scope.isCollapsed = !$scope.isCollapsed;
};

// Collapsing the menu after navigation
// Hide it at certain pages
// Perform actions at page change
$scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {

// Collapsing the menu after navigation
$scope.isCollapsed = false;
$scope.isHidden = (['home', 'signup', 'signin'].indexOf(toState.name) > -1) ? true : false;

// Hide header at certain pages
$scope.isHidden = (['home', 'signup', 'signin'].indexOf(toState.name) > -1) ? true : false;

// Analytics
if (ga) {
ga('send', 'pageview', {
'page': '/#!' + toState.url,
//'title': ''
});
}

});

// Create header menu for User when she/he logins
Expand Down

0 comments on commit 7bfbd4f

Please sign in to comment.