简体   繁体   English

跟踪网站上所有访问者的光标移动

[英]Track cursor movement of all the visitors on a web site

I know that there are many analytics tools available to track cursor movement of all the visitors on a website - these tools basically track the movement by giving a Javascript code which need to be pasted on the website.我知道有许多分析工具可用于跟踪网站上所有访问者的光标移动 - 这些工具基本上通过提供需要粘贴到网站上的 Javascript 代码来跟踪移动。 They all are quite expensive它们都很贵

I am trying to develop it for my own website - a tracking code installed on my website and the cursor movements viewed on some other page/website.我正在尝试为我自己的网站开发它 - 一个安装在我网站上的跟踪代码以及在其他页面/网站上查看的光标移动。

I have seen in Google docs wherein if many people open the doc.我在谷歌文档中看到,如果很多人打开文档。 different cursor are visible in different colors each corresponding to a particular visitor.不同的光标以不同的颜色可见,每种颜色都对应于特定的访问者。 I want to develop similar functionality for website.我想为网站开发类似的功能。

I have tried to Google but I am not able to find a starting point from where I can start developing it.我试过谷歌,但我无法找到可以开始开发它的起点。

Please guide me.请指导我。

What you should look for is attaching a mousemove event listener to the root element of your webpage (body?) and make sure to specify the capture phase by setting the useCapture parameter to true in your call to addEventListener .您应该寻找的是将mousemove事件侦听器附加到网页的根元素(主体?),并确保通过在调用addEventListener 时useCapture参数设置为true来指定捕获阶段。 Check theDOM event model for more details, the diagaramme is pretty self-explanatory.检查DOM 事件模型以获取更多详细信息,diagaramme 是不言自明的。

a quick and dirty exemple should look like this :一个快速而肮脏的例子应该是这样的:

var coords=[];
var callback = function(e) {
    // save your mouse coordinates somewhere
    coords.push({x:e.clientX,y:e.clientY});
}
document.body.addEventListener('mousemove',callback,true);

Of course you'll need to figure out how to push these coordinates at some point to your server (and perhaps just save a sample of the coordinates).当然,您需要弄清楚如何在某个时候将这些坐标推送到您的服务器(也许只是保存一个坐标样本)。

Hope this helps.希望这可以帮助。

Try http://www.clicktale.com/ They have a free option for blogs and small sites.试试http://www.clicktale.com/他们有一个免费的博客和小网站选项。

Deciphering your analytics is going to be the hard part.破译您的分析将是困难的部分。

If you want to do this with jquery, use $(document).mousemove(...).如果您想使用 jquery 执行此操作,请使用 $(document).mousemove(...)。 As long as another tag hasn't prevented propagation, you'll be able to do map the entire page.只要另一个标签没有阻止传播,您就可以映射整个页面。

Caveat:警告:

I've not tested $(document).mousemove(...), it may be $("body").mousemove(...) or $("html").mousemove(...)我没有测试过 $(document).mousemove(...),它可能是 $("body").mousemove(...) 或 $("html").mousemove(...)

删除了我对这篇文章的回答,因为我意识到这不是正确的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM