Tracking iPhone on Yahoo Web Analytics using ASIHTTPRequest

Posted by Mads Mobæk on Stack Overflow See other posts from Stack Overflow or by Mads Mobæk
Published on 2010-04-14T11:33:29Z Indexed on 2010/04/15 21:33 UTC
Read the original article Hit count: 381

I'm trying to track an event in my app using Yahoo Web Analytics. The code I am using looks like

ASIHTTPRequest *yahooTrack = [ASIHTTPRequest requestWithURL:
    [NSURL URLWithString:@"http://s.analytics.yahoo.com/p.pl?a=xxxxxxxxxxxxx&js=no&b=yyyyyyyyyyyy&cf6=zzzzzzzzzzz"]];
yahooTrack.didFinishSelector = @selector(statisticsFinished:);
yahooTrack.delegate = self;
[yahooTrack startAsynchronous];

Then the statisticsFinished looks like:

NSLog(@"Cookies: %@", request.requestCookies);
NSLog(@"Redircount: %d", [request redirectCount]);
NSLog(@"Responsecode %d %@\nMsg: %@", request.responseStatusCode, 
    request.responseStatusMessage, [request responseString]);

And all the information I get back looks correct. Cookies are set, redirectcount is 1 the first time (as it redirects to s.analytics.yahoo.com/itr.pl?.... a normal browser does). Then the redirectcount is 0 for subsequent request until the app is restarted and session cleared. The responseString returns GIF89a.

Even if the data looks correct, Yahoo still won't track. As soon as I call the tracking url directly in my browser it works as expected.

I realize Flurry is a better option, but I'm forced to use Yahoo in this case. Also, using a UIWebView probably would work, but I'm against putting in a webview just for tracking purposes.

Is there any difference in how ASIHTTPRequest and Safari would handle a call to a simple URL as this? Or do you see anything else that could explain why the tracking isn't working?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about yahoo-analytics