Monitoring Google Analytics for iOS

While trying to verify some Google Analytics tracking on Animoto's iOS app I discovered that the GA iOS SDK (at least version 1.3 that we're using) makes itself hard to monitor because it doesn't use the HTTP Proxy configured for the iOS device when it makes its tracking calls, so I can't use a debugging proxy like Charles or Fiddler to observe the traffic. i.e., this method doesn't work.

Instead, I have to share my ethernet internet connection to my iOS device wirelessly and then use a tool like ngrep or Wireshark to monitor the traffic going through the wireless interface (usually "en1").

How I verified:

Using two laptops, I shared my ethernet connection from my first laptop to both my iPod Touch and to my second laptop. I started Charles Proxy on my second laptop and configured my iPod Touch to use it as its HTTP Proxy. Like this:

Using Wireshark to inspect network traffic on both laptops I saw most http traffic coming through on both laptops. However, the GA traffic was showing up only on the first laptop. So, for some reason the GA iOS SDK isn't using the iOS-configured HTTP proxy to send its traffic. I'm not sure if this is a bug or by design, but it does make things harder to monitor.

Interestingly, even when you run the app through the iOS simulator via Xcode, the iOS simulator also refuses to use the OSX-configured proxy for GA traffic (i.e., you still can't use Charles).

So to monitor GA traffic from an iPhone app you have two options:

  1. Using one Mac and one iOS device, share your ethernet internet connection from your Mac to your iOS device
  2. If you have the source code, you can use the iOS simulator via Xcode and the simulator will be using your Mac's internet connection.

And in both cases you need to use ngrep or Wireshark on your Mac to monitor the traffic.

Some discussion on StackOverflow.