8

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?

Note: As far as I know, there is no iOS app to capture HTTP request on the actual device.

Tomer
  • 4,382
  • 5
  • 38
  • 48
  • I'm experiencing the same issue. I'm trying to monitor GA traffic for an iphone app (a native app), but can't see the google analytics traffic. I'm also using Charles proxy, and it's definitely properly configured to proxy SSL traffic from the device under test (I can see login traffic for facebook, twitter and other native apps). However, I can't see GA traffic for the app I'm trying to monitor. Any insights? – Roni Yaniv Jan 10 '12 at 09:45

5 Answers5

2

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

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Jordan Brough
  • 6,808
  • 3
  • 31
  • 31
1

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

1

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).

Till
  • 27,559
  • 13
  • 88
  • 122
  • I might be missing something here, but I don't see Google Analytics requests on my computer (when turning my computer into a proxy) while using fiddler nor Charles. In addition, I couldn't find an iOS version of Charles, or anything similar to it. – Tomer Dec 18 '11 at 13:49
  • Charles is not installed on the device but on your __computer__. As posted above, you will need to setup your iOS-device to use your __computer__ as a proxy. – Till Dec 18 '11 at 14:01
  • As I mentioned (when I wrote "when turning my computer into a proxy"), I have configured my computer as a proxy, and I do see general http requests when I use Fiddler or Charles. HOWEVER, I specifically, don't see Google Analytics requests from an iOS applications - not web applications but native iOS application. (the iOS application uses Google Analytics SDK). – Tomer Dec 18 '11 at 14:44
  • @Till - How are you using Wireshark? Can Wireshark act as a proxy for an iOS device? Are you using Charles and Wireshark together? Are you sharing your internet connection from your computer to your iOS device? – Jordan Brough Jul 25 '12 at 22:16
  • @JordanBrough I am sharing my network connection from my mac to my iOS device and am sniffing the traffic of my mac using wireshark. That way I get to trace the google-analytics traffic. – Till Jul 25 '12 at 22:48
-1

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?

-2

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

Ben Collier
  • 618
  • 4
  • 13