在第二方网站上跟踪用户并收集分析

发布于 2024-11-15 10:16:29 字数 668 浏览 6 评论 0原文

我有一个由 Python/Django 驱动的网站,可以为客户提供服务。所有使用我的服务的客户只需要在他们的页面中包含一个“单个”JS 标签即可。一切正常,但我需要在客户端进行一些跟踪。客户可以使用他们自己的跟踪系统,例如 GA 或其他系统。

我需要收集以下指标并将其发布回我的 Django 应用程序。每个客户端都有一个唯一的密钥,这样我就知道指标来自哪个客户端。是否可以收集以下指标:

  • IP 地址
  • 浏览器信息
  • 操作系统信息
  • 页面 URL
  • 引用 URL
  • 语言
  • 等。

这些与 支持详细信息并且似乎很容易处理。

我还想检查以下指标,但我对如何解决这个问题不太了解,因为 JS 从来都不是我的强项。

  • 新访客或回访者
  • 访问次数
  • 在页面上停留了多长时间
  • 他们最后一次访问该页面是什么时候

是否有脚本可以完成此操作?如果是这样,有人可以给我指出一个吗?

是否可以通过客户端嵌入其页面的脚本来完成我上面要求的操作。由于XSS和跨域请求是否有任何限制?

谢谢。

I've got a Python/Django powered site that offers a service to clients. All the clients who use my service simply need to include a "single" JS tag in their page. All works fine but I need to some tracking on the client side. Clients could be using their own tracking system e.g. GA or something.

I need to gather the following metrics and post it back my Django app. Each client would have an unique key so I know which client, the metrics are coming from. Is it possible to collect the following metrics:

  • IP-address
  • Browser Information
  • OS Information
  • Page URL
  • Referrer URL
  • Language
  • etc.

These are very similar to the ones on Support Details and seem to be pretty easy to handle.

I would like to also check the following metrics but I'm little lost with how to go about this as JS has never been my forte.

  • New or Returning Visitor
  • Number of Visits
  • How long stayed on the page
  • When was the last time they visited the page

Are there scripts that accomplish this? if so, could someone point me to one?

Is it possible to do what I've asked above through the script that the client would embed on their page. Are there any limitations due to XSS and cross-domain requests?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2024-11-22 10:16:29

如果您愿意,您甚至可以使用自己的 GA。

只需让客户端在每个页面视图上通过 AJAX 向您的网站发出 _POST 或 _GET 请求即可。

编辑

用户从您的网站 (mysite.com) 重定向到另一个网站 (externalsite.com),并且您将用户发送到此特定页面:http://externalsite.com/page/21.html#ui=12345,这里要保留的是#ui=12345

现在,外部站点运行一段 Javascript (jQuery) 来执行以下操作:

var hash = window.location.hash;
var data = '<script src="http://mysite.com/stats?ui='+hash+'"></script>';
$('body').append(data);

这克服了 XSS 问题,然后您可以将 stats 页面将用户的 UI + Agent + IP + Time 记录到数据库中并用它做各种数学计算。

You can even use your own GA if you want to.

Just have the client make a _POST or a _GET request to your site via AJAX on every page view.

Edit:

User is redirected from your site (mysite.com) to another site (externalsite.com) and you send the user to this particular page: http://externalsite.com/page/21.html#ui=12345, the thing to retain here is the #ui=12345.

Now the external site runs a snippet of Javascript (jQuery) that does this:

var hash = window.location.hash;
var data = '<script src="http://mysite.com/stats?ui='+hash+'"></script>';
$('body').append(data);

This is overcome your XSS problems and you can then have your stats page record into a database the user's UI + Agent + IP + Time and do all sort of math with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文