简体   繁体   中英

Problem dispatching with google mobile analytics for iphone

I have integrated Google mobile analytics into my iphone app, but for some reason the page views and events are not dispatching.

I put this into my app delegate applicationDidFinishLaunching method (i've x'd out the UA string):

[[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxx-x" dispatchPeriod:10 delegate:self]; NSError *error; [[GANTracker sharedTracker] trackPageview:@"/home" withError:&error];

This is the delegate method:

- (void)trackerDispatchDidComplete:(GANTracker *)tracker eventsDispatched:(NSUInteger)eventsDispatched eventsFailedDispatch:(NSUInteger)eventsFailedDispatch { NSLog(@"Google Analytics Dispatch: succeeded:%i, failed:%i",eventsDispatched,eventsFailedDispatch); }

which prints out the message:

Google Analytics Dispatch: succeeded:0, failed:190

Did anyone else run into this problem?

It turns out all you have to do is delete the application and reinstall. Once you log one incorrect page view (ie one without a "/" at the beginning) nothing will upload to google analytics

The Google Analytics stop sending data when you try to send a non formatted "URL", if it is not initiated with the "/" or contain some specific chars, it will start only returning errors.

The best thing to do is, verify that you are placing the "/" on the beginning of you URL and before sending, format your URL to avoid any problem, by doing:


NSString* pageURLString = [pageURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

Encoding it with NSASCIIStringEncoding, will format the URL properly. The same can be used when tracking an event.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM