开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜