使用NodeJs, Socket.io和VueJs建立实时Web访问分析_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 08:54:26
Original
1429 people have browsed it

网站的访问日志一般我们需要通过后台日志方式获得,能不能在Web浏览器中直接实时观察到当前网站访问情况,有几个活跃用户,活跃访问的页面有哪些?访问这些URL是从哪里来等等信息,对于我们防止爬虫无规则抓取网站能够起到实时监管作用。

开源项目 real-time-analytics-node-socketio-vuejs能够帮助我们实时监控网站的访问情况,它的逻辑是:

1.用户访问网站页面,这些页面都内嵌一段统计代码:

    <b>var</b> socket = io();    <b>var</b> visitorData = {      referringSite: document.referrer,      page: location.pathname    }    socket.emit('visitor-data', visitorData);
Copy after login

2.通过这段代码,客户端javascript会发送自己的访问数据到 NodeJs + Socket.io服务器。

3.NodeJs服务器开始统计计算。

4.将服务器统计数据实时显示到仪表板dashboard。

详细安装介绍:

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!