为什么 Google Analytics 使用 __utm.gif? [英] Why does Google Analytics use __utm.gif?

查看:21
本文介绍了为什么 Google Analytics 使用 __utm.gif?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想了解他们为什么不使用 REST API.

Just trying to understand why they didn't use a REST API.

推荐答案

在 REST 中,客户端向服务器发起资源请求;服务器处理这些请求并返回适当的响应.

In REST, clients initiate requests to servers for resources; servers process those requests and return appropriate responses.

utm.gif 不涉及服务器到客户端的数据传输,而是涉及向另一个方向移动数据.

The utm.gif is not involved in server-to-client data transfer, but instead it's involved in moving data in the other direction.

当然,REST 具有用于客户端与服务器通信的 HTTP 方法(GET 和 POST),实际上,Google Analytics 会指示客户端的浏览器通过 GET 请求将所有分析数据发送到 GA 服务器.更准确地说,GET 请求由请求 URL 和请求标头(例如,Referer 和 User-Agent 标头)组成.

Of course REST has HTTP methods for the client to communicate with servers (GET and POST) and indeed, Google Analytics directs the client's browser to send all analytics data to the GA servers via a GET Request. More precisely, a GET Request is comprised of a Request URL and Request Headers (e.g., Referer and User-Agent Headers).

所有 GA 数据(每一项)都被组装并打包到请求 URL 的查询字符串(?"之后的所有内容).但是为了让数据从客户端(创建它的地方)到 GA 服务器(记录和聚合它的地方)必须有一个 HTTP 请求,所以 ga.js(下载的谷歌分析脚本,除非它是由客户端缓存,作为页面加载时调用的函数的结果)指示客户端组合所有分析数据——例如,cookie、位置栏、请求标头等——将其连接成单个字符串并将其作为查询字符串附加到 URL (http://www.google-analytics.com/__utm.gif?) 并成为请求 URL.

All GA data--every single item--is assembled and packed into the Request URL's query string (everything after the '?'). But in order for that data to go from the client (where it is created) to the GA server (where it is logged and aggregated) there must be an HTTP Request, so the ga.js (google analytics script that's downloaded, unless it's cached, by the client, as a result of a function called when the page loads) directs the client to assemble all of the analytics data--e.g., cookies, location bar, request headers, etc.--concatenate it into a single string and append it as a query string to a URL (http://www.google-analytics.com/__utm.gif?) and that becomes the Request URL.

当然不能有没有资源的HTTP请求;那么资源是客户端从服务器请求的吗?它不需要来自服务器的任何东西,而是想向服务器发送信息.因此,客户端请求的实际服务器资源纯粹是借口——客户端甚至不需要该资源,它只是为了遵守传输协议运营商而请求的.因此,使该资源尽可能小且不引人注目是有意义的,这就是为什么它是 gif 格式的 1 x 1 透明像素的原因.它是最小可能的尺寸和最不密集的图像格式(字节/像素);我认为它有点超过 30 个字节.其他常见格式(例如 jpeg、png、tiff)的 1 x 1 图像更大.

Of course there can't be an HTTP Request without a resource; so resource is the client requesting from the server? It doesn't need anything from the server, instead it wants to send information to the server. So the actual server resource requested by the client is purely pretextual--the resource isn't even needed by the client, it's solely requested to comply with the transmission protocol operator. Therefore, it makes sense to make that resource as small and as unobtrusive as possible, which is why it's a 1 x 1 transparent pixel in gif format. It is the smallest possible size and the least dense image format (bytes/pixel); I think it's a little over 30 bytes. A 1 x 1 image in the other common formats (e.g., jpeg, png, tiff) are larger.

这种在客户端和服务器之间传输数据的通用方案一直存在;很可能有更好的方法来做到这一点,但这是我所知道的唯一方法(满足托管分析服务施加的约束).

This general scheme for transferring data between a client and a server has been around forever; there could very well be a better way of doing this, but it's the only way I know of (that satisfies the constraints imposed by a hosted analytics service).

(Google Analytics 确实有两个 API——数据导出"和管理"--它们都是 RESTful Web 服务.)

(Google Analytics does indeed have two APIs--"Data Export" and "Management"--which are both RESTful Web Services.)

这篇关于为什么 Google Analytics 使用 __utm.gif?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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