aznelite89 aznelite89 - 3 years ago 94
iOS Question

Google analytics not working on iOS 10

I'm had just implemented google analysis and run the app on one of my iOS devices. However, Real time reporting still showing everything 0. I had setup the google analysis as below. Appreciated if any suggestion is given.

AppDelegate.swift didFinishLaunchingWithOptions method : -

guard let gai = GAI.sharedInstance() else {
assert(false, "Google Analytics not confiugured correctly.")
gai.tracker(withTrackingId: "UA-10317xxxx-1")
// Optional: automatically report uncaught exceptions.
gai.trackUncaughtExceptions = true

LoginVC.swift viewWillAppear method : -

override func viewWillAppear(_ animated: Bool) {


LoginVC.swift setupTracker() method : -

private func setupTracker() {
let name = "Login VC"
guard let tracker = GAI.sharedInstance().defaultTracker else { return }
tracker.set(kGAIScreenName, value: name)

guard let builder = GAIDictionaryBuilder.createScreenView() else { return }
tracker.send( as [NSObject : AnyObject])

Answer Source

Need to set the default tracker of GAI in app delegate like below.

GAI.sharedInstance().defaultTracker = gai.tracker(withTrackingId: "<<Trakcing Key goes here>>")

Also to understand what is happening in background we can always check the logs by setting GAI logger level to kGAILogLevelVerbose

Real-time count and almost all GA features are not exactly the real time for me. We might need to give it some time to see the hits in GA dashboard. Typically 10-15 mins

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download