I've added the newest Google Analytics SDK to my iOS application (version 2.0 beta 4). I did the same as the guide says and added this code to app delegate:
// Optional: automatically send uncaught exceptions to Google Analytics.
[GAI sharedInstance].trackUncaughtExceptions = YES;
// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
[GAI sharedInstance].dispatchInterval = 20;
// Optional: set debug to YES for extra debugging information.
[GAI sharedInstance].debug = YES;
// Create tracker instance.
self.tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-TRACKINGID-2"];//UA-33873963-13 - My testing google analytics trackingId
[self.tracker setSessionStart:YES];
[self.tracker setSessionTimeout:60];
Now, on each view I've added this:
self.trackedViewName = @"Main Menu Screen";
Everything works fine, but for some reason 3 out of the 20 screens is not sending themselves to Google and I don't have a clue why. I've searched all over the net, but no one has came across this issue. I figured that if someone familiar with this issue, it's on stack-overflow.
Please help me. Thanks!
For install tracking on iOS, Google Analytics relies on Apple's resettable Identifier for Advertising (IDFA) to match app sessions to campaigns. To accomplish this, Google Analytics relies on Ad Networks to provide and send the IDFA and other campaign information to Google Analytics when an app user clicks on an ad.
You've turned on the User-ID feature in your view settings but haven't configured it. User-ID tracking needs an additional code implementation and if it's not done, your Google Analytics view will contain no data.
As more information has surfaced, it appears that Intelligent Tracking Prevention (ITP) in Safari 14 is not completely blocking Google Analytics. Instead, it's blocking third-party tracking cookies and cross-site scripting requests, which limits portions of Google Analytics.
You can't track Individual users Unfortunately, Google Analytics only allows to use a unique user ID and prohibits sending personal information, username or an IP address. So you can't really see and understand how specific users behave on your site and get valuable data.
I had the same problem some time ago. I bet that you don't call the following methods in your overrides:
[super viewDidLoad]
in your -(void)viewDidLoad
override[super viewDidAppear:animated]
in your -(void)viewDidAppear:(BOOL)animated
override[super viewDidUnload]
in your -(void)viewDidUnload
overrideGAITrackedViewController
Concretely, your methods should look like the following:
-(void)viewDidLoad
{
// call this at the beginning of the overridden methods
self.screenName = @"Some Name";
[super viewDidLoad];
// your remaining code here
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// your remaining code here
}
The most important methods are viewDidLoad
and viewDidAppear:
since especially for real time tracking the viewDidAppear:
shows that this view is currently visible.
EDIT: Since version 3.0 of the Google Analytics SDK the screenName property should be set before calling the viewDidLoad
method of super.
I am using version 3.02 and encountered the same problem. The following fixed my problem:
-(void) viewDidAppear:(BOOL)animated {
self.screenName = @"My Screen"; // set screenName prior to calling super
[super viewDidAppear:animated];
...
}
You definitely want to to call super
because it triggers sending the ga data. It appears to me that the screenName
needs to be set prior to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With