2013-08-16 60 views
1

我添加了所有框架&已實施其他GA API代碼並返回分析。不知道錯誤是什麼?我得到「的選擇sendEventWithCategory沒有已知的實例:在Google Analytics API跟蹤代碼中找不到錯誤

(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]; 
} 

回答

1

試試這個:

[[GAI sharedInstance].defaultTracker sendEventWithCategory:@"Contacts" withAction:@"Invite Button Pressed" withLabel:nil withValue:@1]; 
+0

似乎是正確的,但你可以提高你的答案 –

+0

此代碼對我不起作用。該方法應該是'sendEventWithCategory:withAction:withLabel:withValue:' –

1

,因爲你錯過了Label場你得到錯誤此外,Value應一個NSNumber,和你有一個int

見谷歌的Event Tracking - iOS SDK DOCO,它規定:

事件包含四個字段,你可以用它來描述與 用戶的交互應用內容的:

  • 的NSString類別
  • 的NSString行動
  • 的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]]; 
0

此解決方案工作。

[[GAI sharedInstance].defaultTracker sendEventWithCategory:@"Contacts" withAction:@"Invite Button Pressed" withLabel:nil withValue:@1]; 
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]]; 
相關問題