Reputation: 8444
I'd integrated Google analytics in my app. It is working fine for few screens but not for few other screens(ie, viewcontrollers).
Totally I have 45 screens, but the GAI works only for 19 screens. I'd followed the steps in this documentation.
I'd changed as below in all viewcontrollers,
@interface Myviewcontroller : GAITrackedViewController
and imported GAITrackedViewController
in both .h and .m files
#import "GAITrackedViewController.h"
It's working fine for some screens but not for some other screens. I'm sending the screen names by using self.screenName = @"Home screen";
.
NSLogger is as below for the viewcontrollers that successfully integrated,
VERBOSE: GoogleAnalytics 3.01 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:414): Saved hit: {
parameters = {
"&_u" = ".etno";
"&_v" = "mi3.0.1";
"&an" = My Project;
"&av" = "1.0";
"&cd" = "Home Screen";
"&cid" = "XXXXXXXXXXXXXXXXXXXXXXX";
"&sr" = 320x480;
"&t" = appview;
"&tid" = "UA-XXXXXXX-2";
"&ul" = en;
"&v" = 1;
"&z" = XXXXXXXXXXXXX;
gaiVersion = "3.01";
};
timestamp = "2014-04-28 09:44:17 +0000";
}
But there is no logging for unsuccessfull attempts, after sometime I can see some logging like,
INFO: GoogleAnalytics 3.01 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000007
INFO: GoogleAnalytics 3.01 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000002
INFO: GoogleAnalytics 3.01 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 00000000
I'd checked with all the viewcontrollers, there is no difference in code while integrating Google-Analytics between those screens.
What am I missing? Any Suggestions would be appreciated.
Upvotes: 3
Views: 2723
Reputation: 4731
where did you add self.screenName = @"Home screen";
?
I used to send the page view event instead of using automatic tracking:
//Init once
[GAI sharedInstance].dispatchInterval = 30;
[GAI sharedInstance].trackUncaughtExceptions = NO;
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:gai_id];
And in a common UIViewController class (you can then inherit from this class whenever you want to track the page):
Define a property screenName in .h
@property(nonatomic, copy) NSString *screenName;
Use it in .m
-(void)viewDidAppear:(BOOL)animated{ //Google track [super viewDidAppear:animated];
@try {
[tracker set:kGAIScreenName value:screenName];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
}
@catch (NSException *exception) {
NSLog(@"[ERROR] in Automatic screen tracking: %@", exception.description);
}
}
Remember to set in inherit ViewControllers
-(void)viewDidAppear:(BOOL)animated {
self.screenName = @"my page name";
[super viewDidAppear:animated];
}
Hope this helps.
Upvotes: 2
Reputation: 8444
Eva Madrazo's answer gave me an idea that I went to the GAI tutorial link and there I found an another link for migration guide.
There I found that,
I need to replace,
self.screenName = @"Home screen";
with
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName value:@"Home Screen"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
Now all the screens receiving hits in the Google Analytics.
But, I need to import
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"
to avoid undeclared identifier error.
Upvotes: 1