I’m trying to get google analytics up and running on a monotouch app but no events ever get dispatched successfully, the NSError object is always null. The DispatchCompleted method on the delegate always prints “Successful: 0 – Failed: n”, n = number of pageviews in queue.
I ran the makefile from this url:
https://github.com/mono/monotouch-bindings/tree/master/GoogleAnalytics
which generated a GoogleAnalytics.dll file which I’m trying to use for tracking.
This is the code sample of the test app:
public partial class TestAnalyticsViewController : UIViewController
{
private GanDelegate _delegate;
public override void ViewDidLoad ()
{
_delegate = new GanDelegate();
GoogleAnalytics.GANTracker.SharedTracker.StartTracker("our_id", 0, _delegate);
NSError error;
GoogleAnalytics.GANTracker.SharedTracker.TrackPageView("/Home", out error);
GoogleAnalytics.GANTracker.SharedTracker.Dispatch();
base.ViewDidLoad ();
}
}
public class GanDelegate: GoogleAnalytics.GANTrackerDelegate
{
public override void DispatchCompleted (GoogleAnalytics.GANTracker tracker, int eventsDispatched, int eventsFailedDispatch)
{
Console.WriteLine("Successful: {0} - Failed: {1}", eventsDispatched.ToString(), eventsFailedDispatch.ToString());
}
}
I have also tried uninstalling the app from the device and starting from scratch, but no luck.
I figured out what the problem was… The analytics stuff does not make use of any proxy servers set up on the device, so all calls were being blocked by the firewall