More importantly, how do I fix it?
It's as if backgrounding the app doesn't end the session.
When your app goes into background mode it needs to tell the analytics to stop tracking.
Application Delegate would have something like:
-(void) applicationDidEnterBackground:(UIApplication*)application
{
[[GANTracker sharedTracker] stopTracker];
}
In google's Easy Tracker example, a view controller receives notifications when app state changes. Tracking is stopped when app goes into background (Around line 400).
if ([application applicationState] == UIApplicationStateBackground) {
if (self.state == EasyTrackerStateForeground) {
// Transitioned from foreground to background. Generate the app stop
// event, and stop the tracker.
NSLog(@"Transitioned from foreground to background.");
NSError *error = nil;
if (![[GANTracker sharedTracker] trackEvent:@""
action:@""
label:@""
value:0
withError:&error]) {
NSLog(@"Error tracking foreground event: %@", error);
}
// TODO(fmela): make this time period a constant.
if (![[GANTracker sharedTracker] dispatchSynchronous:2.0]) {
NSLog(@"Synchronous dispatch on background failed!");
}
[[GANTracker sharedTracker] stopTracker];
}
self.state = EasyTrackerStateBackground;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With