数据采集之js埋点
一、后台nginx环境搭建
web点数据采集后台配置nginx:
https://blog.csdn.net/weixin_37490221/article/details/80894827
下载数据源:
wget -O lua-nginx-module-0.10.0.tar.gz https://github.com/openresty/lua-nginx-module/archive/v0.10.0.tar.gz
wget --no-check-certificate -Oecho-nginx-module-0.58.tar.gz 'https://github.com/openresty/echo-nginx-module/archive/v0.58.tar.gz'
wget --no-check-certificate -O nginx_devel_kit-0.2.19.tar.gz https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
wget https://openresty.org/download/openresty-1.9.7.3.tar.gz
wget --no-check-certificate -Oset-misc-nginx-module-0.29.tar.gz 'https://github.com/openresty/set-misc-nginx-module/archive/v0.29.tar.gz'
二、前端埋点
前端页面中需要加载ma.js的脚本代码
<script type="text/javascript">
var _maq = _maq || [];
_maq.push(['_setAccount', 'zaomianbao']); (function() {
var ma = document.createElement('script');
ma.type = 'text/javascript';
ma.async = true;
ma.src = 'http://IP111/ma.js';
var s = document.getElementsByTagName('script')[
];
s.parentNode.insertBefore(ma, s);
})();
</script>
放到后台的前端代码
(function () {
var params = {};
var args = '';
if(document) {
params.domain = document.domain || '';
params.url = document.URL || '';
params.title = document.title || '';
params.referrer = document.referrer || '';
params.bio = document.getElementById("username").innerHTML || '';
params.clickbio = '';
}
document.querySelector("div#page-wrapper .wrapper.wrapper-content.animated.fadeInRight").addEventListener("click",function(e){
params.clickbio = GetChinese(e.target.innerHTML);
console.log(params.clickbio)
args = '';
console.log(params.clickbio)
for(var i in params) {
if(args != '') {
args += '&';
}
args += i + '=' + encodeURIComponent(params[i]);
}
var img = new Image(, );
img.src = 'http://IP111/log.gif?' + args;
})
function GetChinese(strValue) {
if(strValue!= null && strValue!= ""){
var reg = /[\u4e00-\u9fa5]/g;
return strValue.match(reg).join("");
}
}
if(window && window.screen) {
params.sh = window.screen.height || ;
params.sw = window.screen.width || ;
params.cd = window.screen.colorDepth || ;
}
if(navigator) {
params.lang = navigator.language || '';
}
if(_maq) {
for(var i in _maq) {
switch(_maq[i][]) {
case '_setAccount':
params.account = _maq[i][];
break;
default:
break;
}
}
}
for(var i in params) {
if(args != '') {
args += '&';
}
args += i + '=' + encodeURIComponent(params[i]);
}
var img = new Image(, );
img.src = 'http://IP111/log.gif?' + args;
})();
三、后端配置
配置nginx服务器日志格式
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
log_format user_log_format "$u_clickbio||$u_bio||$time_local||$msec||$remote_addr||$status||$body_bytes_sent||$u_domain||$u_url||$u_title||$u_referrer||$u_sh||$u_sw||$u_cd||$u_lang||$http_user_agent||$u_account";
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name localhost;
location /log.gif {
default_type image/gif;
access_log logs/access.log main;
access_by_lua "
local uid = ngx.var.cookie___utrace
if not uid then
uid = ngx.md5(ngx.now() .. ngx.var.remote_addr .. ngx.var.http_user_agent)
end
ngx.header['Set-Cookie'] = {'__utrace=' .. uid .. '; path=/'}
if ngx.var.arg_domain then
ngx.location.capture('/i-log?' .. ngx.var.args .. '&utrace=' .. uid)
end
";
add_header Expires "Fri, 01 Jan 1980 00:00:00 GMT";
add_header Pragma "no-cache";
add_header Cache-Control "no-cache, max-age=0, must-revalidate";
empty_gif;
}
location /i-log {
internal;
set_unescape_uri $u_clickbio $arg_clickbio;
set_unescape_uri $u_bio $arg_bio;
set_unescape_uri $u_domain $arg_domain;
set_unescape_uri $u_url $arg_url;
set_unescape_uri $u_title $arg_title;
set_unescape_uri $u_referrer $arg_referrer;
set_unescape_uri $u_sh $arg_sh;
set_unescape_uri $u_sw $arg_sw;
set_unescape_uri $u_cd $arg_cd;
set_unescape_uri $u_lang $arg_lang;
set_unescape_uri $u_account $arg_account;
log_subrequest on;
access_log logs/user_defined.log user_log_format;
echo '';
}
}
}
数据采集之js埋点的更多相关文章
- JS埋点 小结
今天在看<大型网站性能监测.分析与优化>一书,提到性能监测方式,才知道有这个名词 “JS埋点”. 大概作用:通过在web页面中,添加js脚本,实现对页面性能监测(如加载时间.服务器响应时间 ...
- 网站js埋点
js埋点 1.埋点作用: 页面埋点的作用:其实就是用于流量分析.而流量的意思,包含了很多:页面浏览数(PV).独立访问者数量(UV).IP.页面停留时间.页面操作时间.页面访问次数.按钮点击次数.文 ...
- js埋点(转载)
页面埋点的作用,其实就是用于流量分析.而流量的意思,包含了很多:页面浏览数(PV).独立访问者数量(UV).IP.页面停留时间.页面操作时间.页面访问次数.按钮点击次数.文件下载次数等.而流量分析又有 ...
- 用户行为数据采集核心思维(APP、web数据采集/埋点)
关于数据采集(也就是所谓的埋点),有很多中形式,或者说方法.所有的数据采集都时围绕一个核心的三个点来做区别的处理. 数据采集核心思维三个点: 1.对象: 要采集谁,一个页面.一个按钮,页面或者按钮,就 ...
- Vue前端数据采集 埋点 追踪用户系列行为
什么是埋点? 综合 vue埋点 埋点分析,是网站分析的一种常用的数据采集方法.数据埋点分为初级.中级.高级三种方式.数据埋点是一种良好的私有化部署数据采集方式. 埋点技术如何采集数据,有何优缺 ...
- 网站数据采集|埋点设计|nginx日志文件
数据获取的方式主要可以分为两种: 1.网站日志文件(log files) 页面埋点js自定义的采集. 优缺点: web服务器自带的日志记录功能:优点方便,缺点信息收集不全 自定义的js埋点收集:优点想 ...
- 数字IT基础-数据采集总线
摘要: 日志服务是阿里自产自用的产品,在双十一.双十二和新春红包期间承载阿里云/蚂蚁全站.阿里电商板块.云上几千商家数据链路,每日处理来自百万节点几十PB数据,峰值流量达到每秒百GB, 具备稳定.可靠 ...
- CSS 埋点统计
原文地址: https://my.oschina.net/u/1778933/blog/1608904 CSS 埋点统计 当一个网站或者 App 的规模达到一定程度,需要分析用户在 App 或者网站的 ...
- 不阻塞浏览器的解析,待外部js下载完成后异步执行
网站统计中的数据收集原理及实现(js埋点实现) - lastwhisper - CSDN博客 https://blog.csdn.net/l1212xiao/article/details/80450 ...
随机推荐
- python 数字编码
- SAE J2534介绍
概要 J2534是一种针对与射频相关的ECU进行闪存编程的概念,而不用考虑ECU使用的通信协议.其目的是所有类型的ECU都应当只需一个工具(硬件设备),通常被称为通过式设备.J2534设备和ECU之间 ...
- Hdu 1045 二分匹配
题目链接 Fire Net Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- android studio离线打包mui应用
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/foolish0421/article/details/54618754首先从官网http://www ...
- WPF DrawingVisual详解
在WPF中,如果需要绘制大量图形元素,并且对性能要求严苛的话,最好使用DrawingVisual,当然,你也可以选用 Path类和比Path类更轻量级的Geometry(几何形状)来实现你的需求,但是 ...
- 洛谷 P1266 速度限制 最短路+SPFA算法
目录 题面 题目链接 题目描述 输入输出格式 输入格式 输出格式 输入输出样例 输入样例 输出样例 说明 思路 AC代码 题面 题目链接 P1266 速度限制 题目描述 在这个繁忙的社会中,我们往往不 ...
- ie6中兼容性问题总结
针对firefox ie6 ie7 ie8的css样式中的line-height属性,以前我们大部分都是用!important来hack,对于ie6和firefox测试可以正常显示,但是ie7以上对! ...
- VUE中的style 样式处理的Scope (<style scope>)
在VUE组件中,为了让样式私有化,不对全局造成污染,可以在style标签上添加scoped属性以表示它的只属于当下的模块. 但是这样的话,就会导致无法修改其他第三方组件样式,或者是内嵌的样式,解决方案 ...
- linux 下安装编译配置 QT
注: 1,自己 make qt-everywhere-opensource-src s时,在./configure前主动装好以下3个 sudo apt-get install libX11-dev l ...
- material-ui里面的withStyles是什么?
export default withStyles(styles, { name: 'MuiAppBar' })(AppBar); //这里的作用是什么? withStyles 是一个 HOC 组件, ...