revolunet / angular-google-analytics

Google Analytics tracking for your AngularJS apps
MIT License
652 stars 179 forks source link

Not tracking all the state changes evenif integrated the same way mentioned in the document. #219

Open codalprashant opened 6 years ago

codalprashant commented 6 years ago

It is just tracking the first page. But when the state is changed, it stops tracking the pages and the active user.

Sparksx commented 6 years ago

Hi,

This is due to ui-router update, check this: https://ui-router.github.io/ng1/docs/latest/modules/ng1_state_events.html

codalprashant commented 6 years ago

I managed it using AnalyticsProvider.setPageEvent('$stateChangeStart') in config and

$rootScope.$on('$stateChangeStart',  
      function(event, toState) { 
        Analytics.trackPage($location.absUrl());
}); 

in run section.

revolunet commented 6 years ago

Can we close this issue ?

Sparksx commented 6 years ago

@revolunet No! You need to fix it in your code

AnalyticsProvider.setPageEvent('$stateChangeSuccess'); is now deprecated in angular-ui-router and need to be replaced in your code

BriceN commented 6 years ago

@revolunet @Sparksx I agree that this should be fixed in the library, and not with a workaround.

revolunet commented 6 years ago

so someone should issue a pull request please, i dont use angular anymore sorry

@justinsa is now the main contributor

justinsa commented 6 years ago

My opinion is that the library should stop having an opinion on the route provider used and let the implementer handle that decision. We could then provide a Cookbook as part of the Wiki or the README to explain how to configure different route providers for auto-page tracking or this setPageEvent issue. This library should do Google Analytics the best it can and not need updating due to ng-router or ui-router changes.

If someone wants to issue a PR to fix this issue, great, if not, I will likely make a major version change to alleviate this possibility from being able to happen.