问题
How to track events using Google Analytics? I can track the screen names but I can't track the events. I have code like this:
[[GAI sharedInstance].defaultTracker trackEventWithCategory:@"UIAction"
withAction:@"buttonPress"
withLabel:@"Next button to second page"
withValue:[NSNumber numberWithInt:1]];
But what are the category, action, label and value in it?
I want to track a row selection in a table. So how can I create an event for that?
回答1:
You need to place your code inside the tableView:didSelectRowAtIndexPath:
method to track table row selection. Then you need to name category, action and label properly. I would recommend something like that:
NSString *label = [NSString stringWithFormat:@"Section #%i", indexPath.section];
[[GAI sharedInstance].defaultTracker trackEventWithCategory:@"Table #1"
withAction:@"Select Row"
withLabel:label
withValue:[NSNumber numberWithInt:indexPath.row]];
Actually, you can name category, action and label whatever you want. But it's better to give them convenient names, so it will be easier to find them in your statistics data.
来源:https://stackoverflow.com/questions/23308547/how-to-track-event-of-row-selection-in-table-in-ios