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?
Asked
Active
Viewed 2,816 times
3
-
1Log a screen view when you log the next screen view Google analytics automatically figures out the time on the first screen by when it gets the hit for the second screen. – Linda Lawton - DaImTo Nov 24 '14 at 13:43
1 Answers
6
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.

Community
- 1
- 1

carlodurso
- 2,886
- 4
- 24
- 37