我按照Google指南中提供的说明将Google Analytics(分析)SDK添加到了我的项目中。但是,当我尝试跟踪一些事件时,这是调试输出:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[…]
// Google Analytics
[GAI sharedInstance].trackUncaughtExceptions = YES;
[GAI sharedInstance].dispatchInterval = 20;
[[[GAI sharedInstance] logger] setLogLevel:(PADEV ? kGAILogLevelVerbose : kGAILogLevelError)];
[[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXXXXXX-Y"]; // This is obviously replaced with my tracking ID
return YES;
}
和
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"article"
action:@"read"
label:@""
value:self.post[@"id"]] build]];
日志:
2014-11-12 01:02:25.144 PonzApp[5236:112706] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:208): Hit(s) dispatched: HTTP status -1
2014-11-12 01:02:25.146 PonzApp[5236:112781] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:509): hit(s) Successfully deleted
2014-11-12 01:02:25.147 PonzApp[5236:112781] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 1 hit(s) sent
它说已发送匹配,但HTTP状态奇怪地是
-1
,如果我在仪表板上的“实时”部分进行了检查,则什么也没有出现。有什么事吗
最佳答案
从Google Analytics(分析)tracking setup
Once you've correctly installed the tracking code snippet, you should allow up to 24 hours for data to appear in your account. If it has been more than 24 hours and you're still not seeing any data, take a look at the list of possible reasons below:
一旦系统检测到您的跟踪器,您将开始在实时报告中查看数据。一些数据也可能会出现在标准报告中,但是它不可靠,因为数据需要24小时才能完成处理。
您所有的所有代码看起来都不错,您只需要等待即可。即使是应用程序跟踪,上述内容也相同。我怀疑Google在那边设置新帐户会花费一些时间。
关于events - iOS上的Google Analytics(分析): events not tracked,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26877537/