【发布时间】:2015-12-01 17:04:18
【问题描述】:
我想知道用户观看特定页面的时间(如 Google Analytics)。
我想打开一个 xmlHttpRequest 到我的服务器并将超时设置为大约 30 分钟。 在服务器端,监听请求端,并在服务器端登录。
客户端
$(function($.get('/checktime'))) // start tracking on page load
服务器端
app.use('/checktime',function(req){
var start=new Date()
req.on('end',log)
req.on('disconnect',log)
function log(){
logToServer(new Date()-start) // Time the user spent on the page
}
})
问题:
- 还有其他更好的方法来跟踪用户在页面上花费的时间吗?
- NodeJS 服务器有什么原因会在用户离开页面之前结束连接?
- 应用程序位于
cloudflare后面。 cloudflare 有超时,所以连接会在用户离开页面前结束? - 使用
get或post生成XMLHttpRequest 有什么不同?
谢谢
【问题讨论】:
标签: javascript jquery node.js cloudflare