适用于iOS的Google Analytics不适用于iPad设备

时间:2015-03-27 20:10:00

标签: ios ipad google-analytics-sdk

我刚刚在我正在开发的应用上安装了Google Analytics for iOS。我只是为3个视图做简单的屏幕跟踪。目前,我已经能够获得一切发送谷歌数据(iPhone模拟器,iPad模拟器,iPhone设备)除了iPad设备。是否需要进行某种配置才能使iPad设备正常工作?

我的代码:

在AppDelegate.h中

#import <GoogleAnalytics-iOS-SDK/GAI.h>
AppDelegate.m中的

// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;

// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 5;

// Optional: set Logger to VERBOSE for debug information.
[[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];

// Initialize tracker. Replace with your tracking ID.
[[GAI sharedInstance] trackerWithTrackingId:@"XXXXXXX"];

在所有UIViewControllers&#39; .h文件:

#import <GoogleAnalytics-iOS-SDK/GAITrackedViewController.h>
#import <GoogleAnalytics-iOS-SDK/GAIDictionaryBuilder.h>
#import <GoogleAnalytics-iOS-SDK/GAIFields.h>

@interface ViewController : GAITrackedViewController

在所有UIViewControllers&#39; .m文件:

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // May return nil if a tracker has not already been initialized with a
    // property ID.
    id tracker = [[GAI sharedInstance] defaultTracker];

    // This screen name value will remain set on the tracker and sent with
    // hits until it is set to a new value or to nil.
    [tracker set:kGAIScreenName
       value:@"iPhone Main Screen"];

    // New SDK versions
    [tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}

任何帮助表示赞赏!!

修改:如果有帮助,我使用的是Google Analytics SDK的3.10版本

2 个答案:

答案 0 :(得分:0)

终于弄清楚发生了什么。在Google Analytics信息中心的“实时”标签中,默认情况下,顶部有一个移动设备标记。一旦我删除了它,我就能看到发送的iPad设备消息。

答案 1 :(得分:-1)

Google Analytics(分析)实时 - &gt;概览标签中没有数据? 您的应用是否针对iPad进行了优化?