Open fredmanders opened 8 years ago
What is happening here is that you are starting the script in offline mode and then collecting a bunch of screen and event calls. Then you tell it to inject the GA script and register it. Then you go online. When the script goes online it then re-plays everything in the queue, in order. Do you see how that isn't correct? Your registration happens after all of the events, so they aren't tracked by GA because analytics hasn't been setup properly until the tracker registration happens.
This should be quite easy to fix on your end. Your configuration is fine. You just need to:
Analytics.registerScriptTag();
inthe 'handleOnline' method.Analytics.registerTrackers();
Because you are in offline mode the tracker registration will be added to the queue of commands to run once you go online. You want that to be the first thing in the queue.
Note: The Analytics.createAnalyticsScriptTag
is deprecated because it is not able to support advanced scenarios.
Hi!
I installed your plugin in my Ionic hybrid app. I've also added a send(screenview) on my $stateChangeSuccess to track screens. When the app starts with an internet connection, it perfectly tracks screens and events. When I go offline, it'll store it in the array. When I go back online, it'll send it to Google. Perfect!
But when the app opens without internet connection and THEN gets internet, it'll create the tag and start working perfectly again. But it has lost all the screens and events from before it had internet. Are there any plans to incorporate that? Or am I using it wrong?
My code:
Would it also be possible to keep the screens and events when the app closes completly, by storing them in localstorage?
Thank you for your feedback.