我添加了所有框架&实施其他GA API代码并返回分析。不确定错误是什么?我得到“没有已知的选择器sendEventWithCategory实例:
(IBAction)didTouchOnInviteButton
{
ContactListViewController *contactsViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewControllerId"];
contactsViewController.mode = modeInviteToEvent;
contactsViewController.event = self.event;
[self.navigationController pushViewController:contactsViewController animated:YES];
id <GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker sendEventWithCategory:@"Contacts" withAction:@"Invite Button Pressed" withValue:1];
}
答案 0 :(得分:3)
你可以试试这个,它对我有用
id <GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"Contacts"
action:@"Invite Button Pressed"
label:@"Your label goes here..."
value:[NSNumber numberWithInt:1]] build]];
答案 1 :(得分:1)
试试这个:
[[GAI sharedInstance].defaultTracker sendEventWithCategory:@"Contacts" withAction:@"Invite Button Pressed" withLabel:nil withValue:@1];
答案 2 :(得分:1)
您收到该错误是因为您错过了Label
字段。此外,Value
应为NSNumber
,您还有int
。
请参阅Google的Event Tracking - iOS SDK doco,其中声明:
事件由四个字段组成,您可以使用这两个字段来描述用户的交互 你的应用内容:
- NSString类别
- NSString Action
- NSString标签
- NSNumber(可选)值,解释为64位整数
您的代码应如下所示:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker sendEventWithCategory:@"Contacts"
withAction:@"Invite Button Pressed"
withLabel:@"Your label goes here..."
withValue:[NSNumber numberWithInt:1]];
答案 3 :(得分:0)
此解决方案有效。
[[GAI sharedInstance].defaultTracker sendEventWithCategory:@"Contacts" withAction:@"Invite Button Pressed" withLabel:nil withValue:@1];