In Google Analytics documentation they provide the next code:
Is it possible to track a view without using heritage?
Thanks in advance!
Yes, It is possible. After You setup your defaultTracker in AppDelegate didFinishLaunchingWithOptions method like this;
id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"your_tracking_id"];
[[GAI sharedInstance] setDefaultTracker:tracker];
You can use this in your class that is without heritage;
-(void)viewWillAppear:(BOOL)animated{
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:@"YourViewControllerName"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]]; }
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.