有没有办法确定客户在网页上花费的时间
假设我有一个可以增强的开源 Web 服务器或代理,比如说 apache 或鱿鱼。
有没有办法确定每个客户在网页上花费的时间?
HTTP 当然是无状态的,所以这并不简单,但也许有人知道如何解决这个问题?
Assuming I have an open source web server or proxy I can enhance, let's say apache or squid.
Is there a way to determine the time each client spends on a web page?
HTTP is of course stateless, so it's not trivial, but maybe someone has an idea on how to approach this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 Apache 或 Squid,您几乎无法检测用户在您的页面上花费的时间。
但是,如果您的网页上有一些额外的糖分,您可以:
它免费并且具有很多功能。
但你也会邀请谷歌观看你网站的统计数据......(但这也许可以帮助他们决定是否要买你:-))
With Apache or Squid you hardly can detect the time a user spends on your page.
But with some additional sugar on your webpage you can:
It's free and has a lot of functions.
But you'll also invite Google to watch the stats of your site ... (but maybe that helps them to decide if you wanna buy you :-))
并非没有一些 javascript 不断地在客户端访问您的服务器,然后检查它何时停止(当然,这是假设用户启用了 javascript)。 还有各种(丑陋的)方法来检测使用 javascript 关闭的窗口,但当然这些方法并不总是会触发。 例如。 浏览器崩溃。
我有点想知道你为什么想要这个。 如果一个人浏览网页 3 秒钟,被另一个选项卡/窗口分散注意力,但让您的页面打开 2 小时怎么办? 你得到的答案是2小时,你(可能)想要的答案是3秒。
Not without having some javascript constantly hit your server on the client side and then checking when it stops (but of course that assumes the user has javascript enabled). There are also various (ugly) ways to detect windows being closed with javascript, but of course these won't always trigger. eg. browser crash.
I sort of wonder why you want this anyway. What if a person looks at the web page for 3 seconds, gets distracted by another tab/window but leaves your page open for 2 hours? The answer you get is 2 hours, the answer you (probably) want is 3 seconds.
您可以计算请求该页面到请求下一页之间的时间,但是只有当用户一直停留在该页面上直到请求下一页时,这才是正确的。 即使这样,他可能仍然在原始页面上(例如,他在选项卡中打开了新页面),并且只有在他们浏览到另一页面时才会工作。
唯一确定的方法是使用 Javascript 每隔十秒左右从打开的页面 ping 服务器一次,只是说“我仍在被阅读!”
You could count the time between when the page was requested to when the next page is requested, however this would only be correct if the user stayed on that page the whole time til he requested the next page. Even then he may still be on the original page (e.g. he opened the new one in a tab), and will only work if they do browse to another page.
The only way to know for sure would be to use Javascript to ping the server from the open page every ten seconds or so, just to say "I'm still being read!"
我实际上见过 javascript 分析包,它们不仅通过经常 ping 服务器来跟踪您在页面上停留的时间,而且还准确跟踪屏幕上的内容。 通过测量浏览器窗口的大小以及文档的滚动位置,他们能够准确确定每个元素在屏幕上的长度。 通过跟踪鼠标的位置,也可以很好地猜测它们正在看什么。 我现在找不到链接,但这是一个短篇故事。 如果你真的对人们在看什么、看多久感兴趣,你就可以做到。 您可以跟踪的数量没有太大限制。
另外,只是一个想法,如果您不想对服务器进行过多的 ping 操作,您可以将内容缓冲在内存中,并且仅在获得足够数量的数据时或在页面关闭之前才发送到服务器。
I've actually seen javascript analytics packages where they not only tracked how long you were on the page, by pinging the server every so often, but also kept track of exactly what was on the screen. by measuring the size of your browser window, along with the scroll positions of the document, they were able to determine exactly how long each element was on the screen. By tracking the location of the mouse, can probably get a good guess at what they are looking at too. I can't find the link right now, but here's the short story. If you are really interested in what people are looking at, and for how long, you can do it. There's not much of a limit to how much you can track.
Also, just a thought, If you don't want to ping the server too much, you could keep stuff buffered in memory, and only send to the server when you got a sufficient amount of data, or right before the page closed.
这种指标实际上在几年前就非常流行,当时个人电脑变得更强大,选项卡式浏览器变得流行,而且精确测量变得更加困难。 过去的标准方法是假设人们通常一次只加载一个页面,然后使用服务器日志数据来确定页面浏览之间的时间。 Omniture 和 Urchin(现在的 Google Analytics)等标准分析供应商会对此进行计算。
通常,您设置一个跟踪 cookie 以便能够随着时间的推移识别特定的人/浏览器,但在短期内您可以只使用 IP 地址/用户代理组合。
因此,基本上,您只需处理日志数据并计算页面浏览量之间的增量,即该人在页面上的时间。 您设置一些规则(或者您的分析供应商在幕后执行此操作),例如丢弃/截断超出某个截止时间(例如 10 分钟)的时间,您假设该人实际上并未阅读,而是在窗口/选项卡中打开了页面。
这个数据完美吗? 很明显不是。 但你只需要足够的“足够好”的数据来进行统计分析并得出一些结论。
它对于纵向分析(读者随时间变化的习惯)和网站上不同页面之间的定性比较仍然有用。 (即,在两篇 700 字的文章之间,如果一篇文章的平均阅读时间是另一篇文章的两倍,那么实际上有更多的人正在阅读第一篇文章。)当然,您的网站必须足够繁忙才能有足够的数据点丢弃所有“坏”异常数据点后进行统计上合理的分析。
是的,您可以使用 Javascript 发送 keep-alive 来改善数据。 您可以在 document.onload 之后以给定的时间间隔进行轮询,或者在页面的各个部分设置鼠标悬停事件。
另一种技术是使用 Javascript 将 onclick 事件添加到访问服务器的每个
中。 您不仅可以知道何时有人单击链接将其从您的网站上删除,而且真正复杂的“热点”分析会考虑这样一个事实:如果有人单击页面下方 6 段的链接,那么他们一定已经阅读了那么远。
This kind of metric was actually pretty popular several years ago, before PCs got more powerful and tabbed browsers became popular, and it became harder to measure as accurately. The standard way to do it in the past was to assume people are usually just loading one page at a time, and just use server log data to determine the time between page views. Your standard analytics vendors like Omniture and Urchin (now Google Analytics) calculate this.
Normally, you set a tracking cookie to be able to identify a specific person/browser over time, but in the short term you can just use an IP address/user-agent combo.
So, basically you just crunch the log data and count the delta between to page views as how long the person was on the page. You set some rules (or your analytics vendor does this behind the curtain) like discarding/truncating times beyond some cutoff (say 10 minutes) where you assume the person wasn't actually reading but left the page open in a window/tab.
Is this data perfect? Obviously not. But you just need enough "good enough" data to do statistical analysis and draw some conclusions.
It's still useful for longitudinal analysis (readers' habits over time) and qualitative comparison between different pages on your site. (i.e. between two 700-word articles, if one has a mean reading time twice as long as the other, then more people are actually reading the first article.) Of course, your site has to be busy enough to have enough data points for statistically sound analysis after you throw out all the "bad" outlier data points.
Yes, you could use Javascript to send keep-alives to improve the data. You could just poll at given intervals after document.onload or set mouseover events on sections of your pages.
Another technique is to use Javascript to add an onclick event to every
<a href>
that hits your server. Not only do you then know when someone clicks a link to take them off your site, really sophisticated "hotspot" analysis looks at the fact that if someone clicked a link 6 paragraphs down a page, then they must have read that far.