Monitor Google Analytics requests on an iPhone Application

后端 未结 5 1507
情话喂你
情话喂你 2021-01-12 16:26

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

相关标签:
5条回答
  • 2021-01-12 16:33

    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?

    0 讨论(0)
  • 2021-01-12 16:37

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

    0 讨论(0)
  • 2021-01-12 16:39

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

    0 讨论(0)
  • 2021-01-12 16:42

    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

    0 讨论(0)
  • 2021-01-12 16:52

    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

    0 讨论(0)
提交回复
热议问题