Using Google Analytics in an Ionic App without a plugin
Originally we were using the popular Cordova Google Analytics Plugin. There are advantages to using the plugin, as it interfaces with the native GA SDKs and provides features such as request batching and offline tracking, but we ran into regular issues and a consistently broken Android build. For our simple event tracking and pageview use cases we decided to go with a more straightforward approach and use the analytics.js file directly.
The tracking worked fine when serving Ionic in the browser but did not work on any device, even though the hitCallback was being successfully invoked. (It turns out the hitCallback gets invoked on any response from the server so do not rely on it as an indicator of a successful ‘hit’.)
The problem turned out to be that GA was checking to see whether the current browser protocol was http:// or https:// so it could match it. In an Ionic app the protocol is actually file:// so this needed to be circumvented.
Click here to see the full article.
Very Good. I would know how to redeem the past Referrer for Google Play Thank You :)