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

后端 未结 4 1670
感情败类
感情败类 2020-12-29 15:02

More importantly, how do I fix it?

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

相关标签:
4条回答
  • 2020-12-29 15:45

    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

    0 讨论(0)
  • 2020-12-29 15:46

    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;
      }
    
    0 讨论(0)
  • 2020-12-29 15:48

    This might help: Updating Google Session Tracking

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

    0 讨论(0)
  • 2020-12-29 15:58

    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

    0 讨论(0)
提交回复
热议问题