I’m at a complete loss here with Google Analytics and Ionic. So, here’s the scenario(s).
I have an app that runs, well. It uses other plugins without problem. I’ve tried each of the variants on Google Analytics (in Ionic 1) without any luck whatsoever. With just Google’s code I can get it to report back to GA in the browser. But I’ve tried everything I can think of to get the actual app on device to report back to GA when it loads without any level of success. I’ve followed every tutorial I could find. I installed a whitelist plugin and listed Google and GA. I even tried using the GA code, loaded from index.html and grabbing it through $window.ga after a 3 second delay. Generally, the whole thing comes back to a scenario where the plugin I have installed at that moment is not throwing an error, but calling window.ga.whatever or analytics.whatever just won’t take action even enough to start the session. Sometimes I can get one of them to tell me that window.ga = {}. Sometimes it reports back that it’s undefined. Again, that’s even with waiting for a device to be ready and a 3 second timeout.
I thought it might have been some odd architectural issue, so I spun up a completely new Ionic 2 app and followed those instructions with just the GA plugins and while it runs, it never reports over to Google Analytics. There, too, it seems that Google Analytics isn’t being loaded even with no code of my own added.
I have two GA codes that I’ve tried, too. One is a web property, the other a mobile. Neither seem to matter.
So the question is, what am I not thinking of? I’m guessing that everyone’s Google Analytics reporting didn’t magically stop at one point. Is there some kind of whitelisting that I have to do that maybe I botched in the use of cordova-plugin-whitelist? What about security settings on the device?
Typically I’d post code, but when it’s happening over three or four plugins without error, it doesn’t really feel like a code problem, but more like a policy/device issue. Any ideas? Also, thanks for reading.