Why are my iOS app's session lengths 30 min + in Google Analytics?

给你一囗甜甜゛ 提交于 2019-12-30 01:19:06

问题


More importantly, how do I fix it?

It's as if backgrounding the app doesn't end the session.


回答1:


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;
  }



回答2:


It says if the user has an event with in 30 mins it will treat it as the same session. So all it means is if the user came back within 30 minutes of using your app.

https://developers.google.com/analytics/devguides/collection/ios/v2/sessions




回答3:


This might help: Updating Google Session Tracking

It talks about web, but specifically mentions a 30 minute rule.




回答4:


to end the session when the app goes to background, use

applicationWillResignActive

and maybe put about:blank or something in your webview. (assumption ;))

save the location and reload it in

applicationDidBecomeActive

or read more here



来源:https://stackoverflow.com/questions/9895924/why-are-my-ios-apps-session-lengths-30-min-in-google-analytics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!