ios - 为什么我的 iOS 应用程序在 Google Analytics 中的 session 时长超过 30 分钟?

标签 ios google-analytics

更重要的是,我该如何修复它?

就好像后台应用程序不会结束 session 。

最佳答案

当您的应用进入后台模式时,它需要告诉分析停止跟踪。

Application Delegate 会是这样的:

-(void) applicationDidEnterBackground:(UIApplication*)application
{
[[GANTracker sharedTracker] stopTracker];
}

在谷歌的 Easy Tracker例如, View Controller 在应用程序状态更改时接收通知。当应用程序进入后台时(第 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;
  }

关于ios - 为什么我的 iOS 应用程序在 Google Analytics 中的 session 时长超过 30 分钟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9895924/

相关文章:

iOS Storyboard 设计的应用程序

google-analytics - Google Analytics(分析)未跟踪GATC广告系列跟踪方法

php - google analytics api php,如何访问以某个url开头的所有登陆页面的总 session 数

javascript - Google Analytics Embed API 中的多系列图表

iOS位置后台模式运行时间

ios - 停止 youtube 视频在 xcode/cordova 1.6.1 中打开 youtube 应用程序

ios - 解析查询在只有一个对象时发现两个对象

iOS pod 安装 gcm 和 pchartswift

php - 在 PHP 文件而不是 HTML 中使用 Google Analytics 全局网站标记

google-analytics - 测量下载 -> 安装转换