Manual Screen Tracking
Remember that extending GAITrackedViewController is only one way to track screen views. The manual way is just as easy.
SDK v2
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// returns the same tracker you created in your app delegate
// defaultTracker originally declared in AppDelegate.m
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
// manual screen tracking
[tracker sendView:@"Home Screen"];
}
SDK v3
#import "GAI.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
...
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// returns the same tracker you created in your app delegate
// defaultTracker originally declared in AppDelegate.m
id tracker = [[GAI sharedInstance] defaultTracker];
// This screen name value will remain set on the tracker and sent with
// hits until it is set to a new value or to nil.
[tracker set:kGAIScreenName
value:@"Home Screen"];
// manual screen tracking
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}
Reference
https://developers.google.com/analytics/devguides/collection/ios/v2/screens#manual
https://developers.google.com/analytics/devguides/collection/ios/v3/screens#manual
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…