angularjs service for analytics tracking

This commit is contained in:
Athou
2013-04-24 11:42:39 +02:00
parent fcb6ad2af2
commit 9dab6fa0fa
2 changed files with 17 additions and 2 deletions

View File

@@ -278,8 +278,10 @@ function($scope, $http, $state, $stateParams, $route, $location,
}]);
module.controller('FeedListCtrl', ['$scope', '$stateParams', '$http', '$route',
'$window', 'EntryService', 'SettingsService', 'FeedService', 'CategoryService',
function($scope, $stateParams, $http, $route, $window, EntryService, SettingsService, FeedService, CategoryService) {
'$window', 'EntryService', 'SettingsService', 'FeedService', 'CategoryService', 'AnalyticsService',
function($scope, $stateParams, $http, $route, $window, EntryService, SettingsService, FeedService, CategoryService, AnalyticsService) {
AnalyticsService.track();
$scope.selectedType = $stateParams._type;
$scope.selectedId = $stateParams._id;

View File

@@ -1,5 +1,18 @@
var module = angular.module('commafeed.services', [ 'ngResource' ]);
module.service('AnalyticsService', [ '$state', function($state) {
this.track = function(path) {
path = path || $state.$current.url.prefix;
if (!ga) {
return;
}
ga('send', 'pageview', {
page : path
});
};
} ]);
module.factory('ProfileService', ['$resource', function($resource) {
return $resource('rest/user/profile/');
}]);