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

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

问题描述

在REST中,客户端向服务器发起请求。

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


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

当然,REST为客户端与服务器(GET和POST)进行通信提供了HTTP方法,事实上,Google Analytics会指示客户端浏览器将所有分析数据发送到GA服务器通过GET请求。更确切地说,GET请求由请求URL和请求头(例如,引用者和用户代理头)组成。



所有GA数据 - 每一项都会被汇编并打包到 请求网址的查询字符串 中。 ''之后的所有内容)。但为了使数据从客户端(创建它的地方)到GA服务器(它被记录和聚合的地方),必须有一个HTTP请求,所以ga.js(谷歌分析脚本被下载,除非它是由客户端缓存,作为页面加载时调用的函数的结果)引导客户端汇集所有分析数据 - 例如,cookie,地址栏,请求标题等 - 将它们连接成单个字符串并将其作为查询字符串追加到URL( http:// www。 google-analytics.com/__utm.gif ?),并成为请求网址



当然,如果没有资源,就不会有HTTP请求;所以资源是从服务器请求的客户端?它不需要服务器上的任何东西,而是需要将信息发送到服务器。因此,客户端请求的实际服务器资源完全属于语境 - 客户端甚至不需要该资源,因此只需遵守传输协议运营商的要求。因此,使资源尽可能小而不显眼是合理的,这就是为什么它是gif格式的1 x 1透明像素。它是可能的最小尺寸和最小密度的图像格式(字节/像素);我认为它有点超过30个字节。其他常用格式(如jpeg,png,tiff)中的1​​ x 1图片较大。

这种在客户端和服务器之间传输数据的通用方案一直在附近;这可能是一种更好的方式,但这是我知道的唯一方法(满足托管分析服务所施加的限制)。



(Google分析确实有两个API--数据导出和管理 - 这两个都是REST风格的Web服务。)


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

解决方案

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

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

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

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.

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 does indeed have two APIs--"Data Export" and "Management"--which are both RESTful Web Services.)

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

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