Integration with Google Analytics does not work on iOS

Hi, I am trying to integrate Google Analytics in my iOS app. But it doesn’t work when I open dashbord of analytics, showing users 0 in real time, in fact it always shows this zero.

follow the steps that i have done so far

1. Download the Google Analytics SDK for iOS.

then I just followed this developer.google.com link

these are my codes.

in appdelegate.h - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //analytics // Optional: automatically send uncaught exceptions to Google Analytics. [GAI sharedInstance].trackUncaughtExceptions = YES; // Optional: set Google Analytics dispatch interval to eg 20 seconds. [GAI sharedInstance].dispatchInterval = 20; // Optional: set Logger to VERBOSE for debug information. [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose]; // Initialize tracker. id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-********-*"]; return YES; } in my viewcontroller.h file #import "GAITrackedViewController.h" #import <UIKit/UIKit.h> @interface TopNewsViewController : GAITrackedViewController{ } @property(nonatomic,retain)NSString *screenName; @end in my viewcontroller.m #import "GAIDictionaryBuilder.h" #import "GAI.h" #define kGAIScreenName @"TopNewsViewController" - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; id tracker = [[GAI sharedInstance] defaultTracker]; [tracker set:kGAIScreenName value:@"Home Screen"]; [tracker send:[[GAIDictionaryBuilder createAppView] build]]; } 

The following is a print in my journal

  2014-01-16 19:39:56.766 tempfiles12[844:60b] <Google> To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:@"12d2c8c8808caa10aa1f6d947afc7f33", nil]; 2014-01-16 19:39:57.555 tempfiles12[844:60b] INFO: GoogleAnalytics 3.02 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X000002 2014-01-16 19:39:57.563 tempfiles12[844:1803] ERROR: unable to get the receiver data from the DB! 2014-01-16 19:39:57.571 tempfiles12[844:60b] INFO: GoogleAnalytics 3.02 -[GAITrackedViewController viewDidAppear:] (GAITrackedViewController.m:21): Tracked view controller missing view name. 2014-01-16 19:39:57.611 tempfiles12[844:5317] VERBOSE: GoogleAnalytics 3.02 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:414): Saved hit: { parameters = { "&_u" = ".o-etnoK-L"; "&_v" = "mi3.0.2"; "&an" = tempfiles12; "&av" = "6.0"; "&cid" = "b34bfd7f-45f8-4f4e-84a5-a0d0988e7356"; "&sr" = 768x1024; "&t" = appview; "&tid" = "UA-47216473-1"; "&ul" = en; "&v" = 1; "&z" = 4061780796142886022; TopNewsViewController = "Home Screen"; gaiVersion = "3.02"; }; timestamp = "2014-01-16 14:09:57 +0000"; } 2014-01-16 19:40:17.009 tempfiles12[844:5317] VERBOSE: GoogleAnalytics 3.02 -[GAIRequestBuilder requestGetUrl:payload:] (GAIRequestBuilder.m:177): building URLRequest for https://ssl.google-analytics.com/collect 2014-01-16 19:40:17.011 tempfiles12[844:5317] VERBOSE: GoogleAnalytics 3.02 -[GAIBatchingDispatcher dispatch] (GAIBatchingDispatcher.m:499): Sending hit(s) GET: https://ssl.google-analytics.com/collect?_v=mi3.0.2&av=6.0&_u=.o-etnoK-L&ul=en&v=1&an=tempfiles12&t=appview&sr=768x1024&cid=b34bfd7f-45f8-4f4e-84a5-a0d0988e7356&tid=UA-47216473-1&ht=1389881397577&qt=19431&z=4061780796142886022 2014-01-16 19:40:17.232 tempfiles12[844:60b] INFO: GoogleAnalytics 3.02 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:157): Hit(s) dispatched: HTTP status 200 2014-01-16 19:40:17.233 tempfiles12[844:5317] INFO: GoogleAnalytics 3.02 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:426): hit(s) Successfully dispatched 2014-01-16 19:40:17.240 tempfiles12[844:5317] INFO: GoogleAnalytics 3.02 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:167): 1 hit(s) sent 

Dashboard

enter image description here

+7
ios objective-c analytics google-analytics
source share
2 answers

Wow. I have found the answer.

in our viewcontroller.m file

we need to use the screen name variable already defined in GAITrackedViewController.m

so in my case the variable name was "screenname" and I did this by declaring one variable in my viewcontroller.h.

So, I deleted this line and I added this line

"self.screenname = @" my screen name ";

NOw its working.

Other things work.

+3
source share

Another reason if it doesn't work: you need to wait 24-48 hours after creating the Google Tracking ID to see the results. (Even for real time)

See also: Google Analytics for iOS: Events Not Tracked

+5
source share

All Articles