Skip to content

Commit

Permalink
google analytics bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandoche Adittane committed Jul 19, 2016
1 parent 73706dd commit a23aca8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .grunt/grunt-gh-pages/gh-pages/src
Submodule src updated from 96417b to 54c3af
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<script src="scripts/controllers/contact.js"></script>
<script src="scripts/services/botsdata.js"></script>
<script src="scripts/directives/botbar.js"></script>
<script src="scripts/services/analyticsservice.js"></script>
<!-- endbuild -->
</body>
</html>
14 changes: 5 additions & 9 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ angular
.otherwise({
redirectTo: '/alex'
});
}).run(['$rootScope', '$location', '$window', function($rootScope, $location, $window){
$rootScope
.$on('$stateChangeSuccess',
function(event){
if (!$window.ga)
return;
$window.ga('send', 'pageview', { page: $location.path() });
});
}]);
}).run(function($rootScope, $location, analyticsService) {
$rootScope.$on('$routeChangeSuccess', function() {
analyticsService.recordPageview($location.url());
});
});
16 changes: 16 additions & 0 deletions app/scripts/services/analyticsservice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

/**
* @ngdoc service
* @name happybotsApp.analyticsService
* @description
* # analyticsService
* Service in the happybotsApp.
*/
angular.module('happybotsApp')
.service('analyticsService', function () {
this.recordPageview = function(url) {
ga('set', 'page', url);
ga('send', 'pageview');
};
});
18 changes: 18 additions & 0 deletions test/spec/services/analyticsservice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

describe('Service: analyticsService', function () {

// load the service's module
beforeEach(module('happybotsApp'));

// instantiate service
var analyticsService;
beforeEach(inject(function (_analyticsService_) {
analyticsService = _analyticsService_;
}));

it('should do something', function () {
expect(!!analyticsService).toBe(true);
});

});

0 comments on commit a23aca8

Please sign in to comment.