I am trying to use Google Analytics in my iOS app. I have tracked the events and screens. I want to track the time user spent on specific screens. How I can achieve this?
When it comes to Google Analytics I like to be creative. Here's my possible solution:
- (void)viewDidAppear
{
_startingTime = [NSDate date];
- (void)viewWillDisappear:(BOOL)animated {
_endingTime = [NSDate date];
NSTimeInterval distanceBetweenDates = [_startingTime timeIntervalSinceDate:_endingTime];
NSInteger minutesBetweenDates = distanceBetweenDates / 60;
Then, you might use Screens to send the data to your reports.
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName
value:@"Home Screen %d", minutesBetweenDates];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
For more precision on the time interval you might be interested in this method .
Alternatively, you may use Events to achieve the same objective.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.