如何衡量用户的访问时间 [英] How to measure visiting time of a user

查看:131
本文介绍了如何衡量用户的访问时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢衡量用户在我的webapp的特定页面上花费的时间。首先,我考虑在浏览器中捕获onunload / onbeforeunload事件,并通过XMLHttpRequest通知服务器,用户现在就离开:

I like to measure the time a user spent on a particualr page of my webapp. First i thought about catching the onunload/onbeforeunload event in the browser and notify the server via a XMLHttpRequest that the user is leaving now like:

<body onunload="userLeaves('/url/to/current/page',xxx);" ...> ... </body>

其中xxx是呈现页面时的初始tiemstamp。

where xxx is the inital tiemstamp when the page was rendered.

不幸的是,这个解决方案并不适用于所有浏览器(例如Opera)。所以我的第二个想法是不断ping服务器。要计算访问时间,有人必须花费最后一次ping时间并从初始时间戳中减去它。但我不认为这是一个很好的解决方案,尤其是当用户打开3或5个标签并且每个标签每500毫秒触发事件时...

Unfortunately this solution doesnt work in all browser (e.g. Opera). So my second idea was to ping the server constantly. To calculate the visiting time someone has to take the last ping time and subtract it from the inital timestamp. But i dont think thats a good solution either especially when a user has opend 3 or 5 tabs and every tab is firing events every 500 ms ...

你将如何衡量访问时间?有人更好地获得在一个特定页面上花费的时间吗?

how would you measure the visiting time? has someone a better idea to obtain the time spent on one particualr page?

推荐答案

Google Analytics等工具使用的方法是该访问时间被测量为用户点击第一页到他们在单个访问中到达最后一页的时间。单次访问被定义为一个用户(cookie)的一系列页面查看,其中每次访问都足够接近前一次访问。我不知道这个限制是什么。

The approach used by such tools as Google Analytics is that visit time is measured as the time the user hit the first page to the time they hit the last page within a single "visit". A single visit is defined as a series of page views by one user (cookie) where each visit is sufficiently close to the previous in time. I don't know what that limit is however.

根据我的经验,这些带卸载事件等的技巧接近于侵入性而用户没有欣赏他们。因此,它们与更加被动的方法相比几乎没有任何价值,例如构建访问Cookie和页面查看数据。

In my experience, these kinds of tricks with unload events and so forth are bordering on being intrusive and users don't appreciate them. As such they add little to no value over a more passive approach like constructing a visit from cookies plus page view data.

这篇关于如何衡量用户的访问时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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