Monitor Google Analytics requests on an iPhone Application

I am trying to monitor the Google Analytics request on an iPhone application and for some reason I don’t see any of GA the requests. However I can see and uniquely identify the traffic on the google analytics interface.
I have tried using several technics including using Fiddler/Charles as a proxy and overlap the computer ip. While I can see many http request using this technic, I don’t see any request that are related to Google Analytics.

What can be done to capture these requests?

  • iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication
  • iOS9 does not load insecure resources from a secure page (SSL/HTTPS)
  • HTTP “Content-Disposition: attachment” and downloading files on iOS web browser
  • Why are my iOS app's session lengths 30 min + in Google Analytics?
  • Swift http request use urlSession
  • Can I use Google Analytics to sort out the statistics of my iOS App?
  • Note:
    As far as I know, there is no iOS app to capture HTTP request on the actual device.

    5 Solutions Collect From Internet About “Monitor Google Analytics requests on an iPhone Application”

    The problem is that the tracking calls that the Google Analytics SDK makes are not using the iOS HTTP proxy.

    If GA tracking calls doesn’t use the iOS proxy they obviously won’t be sent to Charles (or Fiddler or whatever) and it can’t track anything. The only way to monitor these calls is to do something like share your ethernet internet connection on your computer to your iOS device wirelessly and use a tool like ngrep or WireShark to monitor the traffic coming through your wireless interface (usually en1 on a Mac). Here’s an example ngrep command:

    sudo ngrep -d en1 port 80 | grep --color -E -C 3 '(google|utm.gif)'
    

    (You can easily install ngrep via homebrew on a Mac)

    Or with Wireshark you can start monitoring your wireless interface (en1 on a Mac) and type “http” into the “Filter:” box to filter down to http traffic.

    If you have the source code for the app then another option to avoid ‘internet connection sharing’ is to run the app via the iOS Simulator in Xcode on your Mac so that it uses your Mac’s internet connection. The GA code actually still refuses to use the OSX-configured proxy (i.e., you still can’t use Charles) but you can then use ngrep or Wireshark (as above) on your Mac without having to set up internet connection sharing.

    Here’s a post on my blog with more details: Monitoring Google Analytics for iOS

    Google Analytics does request via HTTPS -> SSL encrypted. You should in fact see their requests using Charles. Just, you won’t be able to see the content of those requests.

    To negate your note right away; you can certainly see HTTP/s requests from the device itself as well using Charles.

    See this blog entry for more on Charles’ configuration.

    Make sure you understand the fundamental difference between HTTP and HTTPS.

    Edit: I was all wrong. Google Analytics does not use HTTPS for the tracking but plain HTTP (TCP Port 80). I have yet to find out on why the tracking requests are not visible when using Charles. They are however visible when using Wireshark.

    -> Use Wireshark for tracing Google Analytics activity.

    To get that accomplished, I am sharing the internet connection from my Mac with my iOS device as follows:

    System Preferences -> Sharing -> Internet Sharing -> Share your connection from:Ethernet, To computers using:Wifi

    Once connected, I make sure to minimize the network traffic of the Mac itself to prevent noisy tracing.

    The rest is Wireshark magic and a bit hard to describe off the head (can not do it at this moment).

    With the latest version of Charles you can see GA tags and it’s a bit easier then using the approach from Jordan Brough above. Steps:

    • Download the latest version of Charles.
    • Launch Charles and set your iOS device to use Charles as a proxy in
      Settings->Wi-Fi [networkName]. Tap the I icon then scroll down to the
      HTTP Proxy section. Tap Manual and add the server IP and port 8888.
    • Launch Mobile Safari and navigate to
      http://www.charlesproxy.com/getssl. Install the Charles Root Cert.
    • In Charles add the GA server in Proxy->SSL Proxying Settings. The GA
      server is ssl.google-analytics.com.
    • Quit Charles and restart.

    Note that the GA SDK batches requests (although sometimes it looks like it makes single requests on occasion as well) so if you think you do not see your tag make sure you scroll through the batched request. If you are looking for screen views the parameter is cd.
    GA tags in CharlesProxy

    I set up the machines as you suggested and it all works just fine. Wireshark on a win7 with adhoc network where an ipad is signed in.
    If i use safari on the ipad i emidiately get the requests (with filter http.host contains “google”) to google analytics, __utm.gif as it should be. However in the app I can’t find any request to analytics. So I’m not sure what to search for in wireshark. Is the filter on “http.host contains “google”” alright? Or do I have to define some different filters? Maybe the SDK isn’t using the same __utm.gif request as in HTML?

    It looks like the iOS SDK for Analytics is using a different protocol than HTTP / HTTPS so it’s not showing up in Charles.