revolunet / angular-google-analytics

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

`$window.ga has initialized` event #198

Closed machulav closed 7 years ago

machulav commented 7 years ago

I need to know when the $window.ga will be initialized by the angular-google-analytics wrapper and then run my custom script which should let me know whether AdBlocker works on the page and block $window.ga:

if (!this._globalGA || !this._globalGA.create || !this._globalGA.loaded) {
      this._loggerService.log('AdBlocker detected - Case 2: Google Analytics disabled');
}

Do you have such event in the plugin? How can I know that $window.ga has initialized already?

Thank you!

machulav commented 7 years ago

@revolunet @deltaepsilon @justinsa do you have an idea how to do this?

justinsa commented 7 years ago

@machulav This library doesn't know about the state of $window.ga beyond the script being injected on the page. All commands are run through the standard interface with the GA function call. That function simply pushes to an array and the GA script does its business with the calls this library makes to the ga function.

You might want to read through the GA documentation to figure out if the ga object exposes any events or state information that you can connect to.

machulav commented 7 years ago

@justinsa thank you for the answer!