如何使用Google Analytics跟踪用户对MFMailViewController的操作?我想看看人们如何使用它;即按取消,发送电子邮件,删除消息等。
答案 0 :(得分:2)
在委托中实施以下方法:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
id tracker = [[GAI sharedInstance] defaultTracker];
switch (result) {
case MFMailComposeResultCancelled:
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" action:@"event_action" // Event action (required)
label:@"Cancelled" // Event label
value:nil] build]]; // Event value
break;
case MFMailComposeResultSaved:
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" action:@"event_action" // Event action (required)
label:@"Saved" // Event label
value:nil] build]]; // Event value
break;
case MFMailComposeResultSent:
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" action:@"event_action" // Event action (required)
label:@"Sent" // Event label
value:nil] build]]; // Event value
break;
case MFMailComposeResultFailed:
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui_action" action:@"event_action" // Event action (required)
label:@"Failed" // Event label
value:nil] build]]; // Event value
break;
default:
break;
}
}