谷歌分析如何生成唯一的ID?
是通过javascript完成的吗?或者它是否在某个地方发出包含一些信息的请求,并且 ga 发回了保存在 cookie 中的响应?
is it done through javascript? or is it making a request somewhere with some info and ga sends back a response that is saved in the cookie?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你在问什么,但 ID(无论是否是 Google Analytics)都是在服务器上生成的。
从安全角度来看,有关客户端-服务器应用程序的一般经验法则是您永远不应该信任用户。在这种情况下也是如此。
从逻辑上讲,生成一些ID然后在服务器上与其绑定是没有意义的。
I'm not sure what you're asking, but an ID, Google Analytics or not, is generated on the server.
From a security perspective, the general rule of thumb about Client-Server applications is that you should never trust the user. Same in this case.
Logically, it doesn't make sense to generate some ID and then bind with it on the server.
它必须在 JavaScript 中完成,因为在
ga.js
请求和发送的__utm.gif
信标之间没有对 ID 发出任何额外请求。它看起来像是随机数和当前日期的组合,但我无法确认这是否正确。我之前在跟踪脚本中使用的一件事是在服务器上生成 ID 并将其注入到初始 JavaScript 中,但我在 ga.js 中没有看到类似的内容。然而, ga.js 很难阅读,所以我可能会遗漏一些东西。
It must be done in the JavaScript because there's no additional request made for an ID between the
ga.js
request and the__utm.gif
beacon being sent. It looks like a combination of a random number and the current date but I can't confirm if that's correct.One thing I used in a tracking script before was to generate an ID on the server and inject it into the initial JavaScript but I don't see anything like that in
ga.js
. However,ga.js
is quite hard to read so I could be missing something.