开发者

JQuery Plugin - Record Time Spent on Webpage

开发者 https://www.devze.com 2022-12-29 23:53 出处:网络
I want to record time spent on webpages. Is there an appropriate JQu开发者_C百科ery plugin written for this? I could then record the value of the timer in a variable and insert to a database.

I want to record time spent on webpages. Is there an appropriate JQu开发者_C百科ery plugin written for this? I could then record the value of the timer in a variable and insert to a database.

JJH


Google Analytics is a great solution for this. A better, faster wheel has already been invented.


If you're hell bent on this feature it's quite easy:

var interVal = 60000; // 60 seconds (adjustable)
var totalTime = 0;
function LogTime() {
     totalTime += interVal;
     $.ajax { /* Your ajax call to tell the server totalTime */ }
     setTimeout("LogTime()", interVal);
}

setTimeout("LogTime()", interVal);

But Diodeus is probably right, there are better ways to get this metric.

0

精彩评论

暂无评论...
验证码 换一张
取 消