我刚刚在我一直在开发的应用程序上安装了适用于 iOS 的 Google Analytics。我只是对 3 个视图进行简单的屏幕跟踪。目前,除了 iPad 设备外,我已经能够获取发送 Google 数据的所有内容(iPhone 模拟器、iPad 模拟器、iPhone 设备)。是否需要进行某种配置才能使 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 的 .h 文件中:
#import <GoogleAnalytics-iOS-SDK/GAITrackedViewController.h>
#import <GoogleAnalytics-iOS-SDK/GAIDictionaryBuilder.h>
#import <GoogleAnalytics-iOS-SDK/GAIFields.h>
@interface ViewController : GAITrackedViewController
在所有 UIViewControllers 的 .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]];
}
任何帮助表示赞赏!
编辑:如果有帮助,我正在使用 3.10 版的 Google Analytics SDK