mgonto / angularytics

The solution to tracking page views and events in a SPA with AngularJS
MIT License
630 stars 70 forks source link

Unable to track events #54

Closed gaurav150493 closed 6 years ago

gaurav150493 commented 7 years ago

I am using your module it is tracking the page views but it is not tracking my events. I have included angularytics.min.js in my page and this is the other code i have used.

app.js

.config(function($stateProvider, $urlRouterProvider, AngularyticsProvider){
    AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);
    $urlRouterProvider.otherwise('/');
    $stateProvider
    .state('upload', {
        url: "/:user_id",
        templateUrl: 'templates/upload.html',
        controller: 'uploadCtrl'
    })
});

controller

.controller('uploadCtrl', function(Angularytics, $scope){
$scope.trackDownload = function(){
        Angularytics.trackEvent("Home Category", "Button clicked");
        console.log('tracked');
    }
});

html <a href="#" ng-click="trackDownload()">Click Me!</a>

sks40gb commented 7 years ago

Looks like you have missed the init method to invoke within run method.

.run(function (Angularytics) { Angularytics.init(); });