iPhone SDK 自定义变量的 GANTracker 给出错误 195946409
我想使用谷歌分析来跟踪某些用户的页面浏览量和会话。 为此,我(想)使用最新 (v1.1) GANTracker 版本支持的自定义变量。
在我的 appHeader 中,我有这样的代码:
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxxx-x"
dispatchPeriod:10
delegate:nil];
NSError *error1;
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:0
name:@"userSession"
value:@"username"
scope:kGANSessionScope
withError:&error1]){
NSLog(@"error1 %@", error1);
}
NSError *error2;
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:1
name:@"userSession"
value:@"username"
scope:kGANPageScope
withError:&error2]){
NSLog(@"error2 %@", error2);
}
当我启动我的应用程序时,我收到这些错误:
error1: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)"
error2: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)"
在打开我想要跟踪的页面的函数中,我输入了以下内容:
NSError * error;
if(![[GANTracker sharedTracker] trackPageview:@"/pagename"]
withError:&error]){
NSLog(@"%@", error);
}
如果我省略 setCustomVariableAtIndex 函数,则不会返回任何错误
,页面浏览量将记录在分析中但使用自定义变量我什么也得不到。
有谁知道我如何解决这个问题?
I would like to use google analytics to track pageviews and sessions by certain users.
To do this I (would like to) use a custom variables which are supported by the newest (v1.1) GANTracker version.
in my appHeader I have this code:
[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxxxx-x"
dispatchPeriod:10
delegate:nil];
NSError *error1;
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:0
name:@"userSession"
value:@"username"
scope:kGANSessionScope
withError:&error1]){
NSLog(@"error1 %@", error1);
}
NSError *error2;
if(![[GANTracker sharedTracker] setCustomVariableAtIndex:1
name:@"userSession"
value:@"username"
scope:kGANPageScope
withError:&error2]){
NSLog(@"error2 %@", error2);
}
when I start my app I get these errors:
error1: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)"
error2: Error Domain=com.google.googleanalytics.GANTrackerError Code=195946409 "The operation couldn’t be completed. (com.google.googleanalytics.GANTrackerError error 195946409.)"
in the function that opens a page I want to track I put this:
NSError * error;
if(![[GANTracker sharedTracker] trackPageview:@"/pagename"]
withError:&error]){
NSLog(@"%@", error);
}
this returns no errors
if I leave out the setCustomVariableAtIndex function the pageview is logged in analytics but with the custom vars I get nothing.
Does anyone have an idea on how I can solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,并在 Google 的示例代码中偶然发现了答案。
如果将索引设置为零,则自定义变量会引发错误。您的第一个变量需要使用索引 1。这会将上面的代码片段更改为如下所示...
I hit the same problem and stumbled upon the answer in Google's sample code.
The custom variables throw an error if you set the index to zero. Your first variable needs to use index 1. This would change the above code snippet to look like this...