在 iPhone 应用程序上监控 Google Analytics 请求 [英] Monitor Google Analytics requests on an iPhone Application

查看:20
本文介绍了在 iPhone 应用程序上监控 Google Analytics 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试监控 iPhone 应用程序上的 Google Analytics 请求,但出于某种原因,我没有看到任何 GA 请求.但是,我可以在 google 分析界面上看到并唯一标识流量.我尝试过使用多种技术,包括使用 Fiddler/Charles 作为代理并重叠计算机 ip.虽然我可以看到许多使用这种技术的 http 请求,但我没有看到任何与 Google Analytics(分析)相关的请求.

可以采取哪些措施来捕获这些请求?

注意:据我所知,目前还没有 iOS 应用可以在实际设备上捕获 HTTP 请求.

解决方案

问题在于 Google Analytics SDK 进行的跟踪调用未使用 iOS HTTP 代理.

如果 GA 跟踪调用不使用 iOS 代理,它们显然不会发送给 Charles(或 Fiddler 或其他),并且无法跟踪任何内容.监视这些呼叫的唯一方法是在您的计算机上执行诸如共享您的以太网互联网连接之类的操作,以便无线连接您的 iOS 设备,并使用 ngrepWireShark 来监控通过您的无线接口(在 Mac 上通常为 en1)的流量.这是一个示例 ngrep 命令:

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

(您可以在 Mac 上通过 homebrew 轻松安装 ngrep)

或者使用 Wireshark,您可以开始监控您的无线接口(Mac 上的 en1)并在过滤器:"框中键入http"以过滤到 http 流量.

如果您有应用程序的源代码,那么避免互联网连接共享"的另一个选择是通过 Mac 上 Xcode 中的 iOS 模拟器运行应用程序,以便它使用您 Mac 的互联网连接.GA 代码实际上仍然拒绝使用 OSX 配置的代理(即,您仍然无法使用 Charles),但您可以在 Mac 上使用 ngrep 或 Wireshark(如上所述),而无需设置互联网连接共享.

这是我博客上的一篇文章,其中包含更多详细信息:监控 iOS 版 Google Analytics(分析)

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.

解决方案

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

这篇关于在 iPhone 应用程序上监控 Google Analytics 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆