How to track event of row selection in table in iOS

佐手、 提交于 2020-01-06 10:55:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!