(function () {
uba_initUbaMask();
window.onresize = function() {
uba_initUbaMask();
};
document.addEventListener('click', function(e){
var objtag = e.target.nodeName;
if (objtag != 'BODY' && e.isTrusted) {
var params = {};
var nowDate = new Date();
//Document对象数据
params.ct = objtag;
params.c = e.target.outerHTML.substr(0,2000);
params.st = e.target.innerText.substr(0,2000);
params.t = 'clk';
params.tm = (nowDate.getFullYear() + '-' + (nowDate.getMonth() + 1) + '-' + nowDate.getDate()+' '+nowDate.getHours()+':'+nowDate.getMinutes()+':'+nowDate.getSeconds());
if (document) {
params.domain = document.domain || '';//获取域名
params.url = document.URL || '';//当前Url地址
params.title = document.title || '';
params.referrer = document.referrer || '';//上一跳路径
}
//Window对象数据
if (window && window.screen) {
params.sh = window.screen.height || 0;//获取显示屏信息
params.sw = window.screen.width || 0;
params.cd = window.screen.colorDepth || 0;
params.sx = e.screenX|| 0;
params.sy = e.screenY|| 0;
}
/* 获取区域划分 */
params.a1 = uba_getModule(e.target);
//navigator对象数据
if (navigator) {
params.lang = navigator.language || '';//获取所用语言种类
}
//解析_maq配置
if (_maq) {
for (var i in _maq) {//获取埋点阶段,传递过来的用户行为
switch (_maq[i][0]) {
case '_setAccount':
params.u = _maq[i][1];
break;
case '_ssys':
params.s = _maq[i][1];
break;
default:
break;
}
}
}
//拼接参数串
var args = '';
for (var i in params) {
if (args != '') {
args += '&';
}
args += i + '=' + encodeURIComponent(params[i]);//将所有获取到的信息进行拼接 encodeURIComponent
}
var img = new Image(1, 1);
var src = 'http://218.85.140.83:8000/ua/1.gif?'+ args;
img.src = src;
}
});
/* 初始化用户行为分析模块划分 */
function uba_initUbaMask() {
/* 页面判断 */
if (document.URL.indexOf('/wui/index.html#/main/portal/portal-') !== -1) {
/* 全文检索 */
uba_createMask({'selector':'.search', 'path':'全文检索'});
uba_createMaskMultiple({'selector':'.search .searchMenuItem', 'path':'全文检索_', 'textFrom':'title'});
/* 菜单 START */
uba_createMask({'selector':'div.powerMenu div:nth-child(1)', 'path':'菜单_首页'});
uba_createMask({'selector':'div.powerMenu div:nth-child(2) div.powserMenuItem', 'path':'菜单_流程审批'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(2) .xyPowserMenuItem', 'path':'菜单_流程审批_'});
uba_createMask({'selector':'div.powerMenu div:nth-child(3) div.powserMenuItem', 'path':'菜单_人力自助'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(3) .xyPowserMenuItem', 'path':'菜单_人力自助_'});
uba_createMask({'selector':'div.powerMenu div:nth-child(4) div.powserMenuItem', 'path':'菜单_文档管理'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(4) .xyPowserMenuItem', 'path':'菜单_文档管理_'});
uba_createMask({'selector':'div.powerMenu div:nth-child(5) div.powserMenuItem', 'path':'菜单_日程管理'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(5) .xyPowserMenuItem', 'path':'菜单_日程管理_'});
uba_createMask({'selector':'div.powerMenu div:nth-child(6) div.powserMenuItem', 'path':'菜单_会议管理'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(6) .xyPowserMenuItem', 'path':'菜单_会议管理_'});
uba_createMask({'selector':'div.powerMenu div:nth-child(7) div.powserMenuItem', 'path':'菜单_技术支持'});
uba_createMaskMultiple({'selector':'div.powerMenu div:nth-child(7) .xyPowserMenuItem', 'path':'菜单_技术支持_'});
/* 菜单 END */
/* 最新动态 */
uba_createMask({'selector':'#item_8', 'path':'最新动态'});
uba_createMaskMultiple({'selector':'#titleContainer_8 div[role="tablist"] div[role="tab"] div', 'path':'最新动态_', 'textFrom':'title'});
/* 工作待办 */
uba_createMask({'selector':'#item_17', 'path':'工作待办'});
uba_createMask({'selector':'#content_17 li:nth-child(1)', 'path':'工作待办_公文待办'});
uba_createMask({'selector':'#content_17 li:nth-child(2)', 'path':'工作待办_公文待阅'});
uba_createMask({'selector':'#content_17 li:nth-child(3)', 'path':'工作待办_业务审批'});
uba_createMask({'selector':'#content_17 li:nth-child(4)', 'path':'工作待办_报账审批'});
uba_createMask({'selector':'#content_17 li:nth-child(5)', 'path':'工作待办_我的邮箱'});
/* 快捷通道 */
uba_createMask({'selector':'#item_27', 'path':'快捷通道'});
uba_createMaskMultiple({'selector':'#item_27 div.portal_fastTrack_item', 'path':'快捷通道_', 'selectByText':true});
/* 公共信息 */
uba_createMask({'selector':'#item_6', 'path':'公共信息'});
uba_createMaskMultiple({'selector':'#titleContainer_6 div[role="tablist"] div[role="tab"] div', 'path':'公共信息_', 'textFrom':'title'});
/* 党建及精神文明建设 */
uba_createMask({'selector':'#item_16', 'path':'党建及精神文明建设'});
uba_createMaskMultiple({'selector':'#titleContainer_16 div[role="tablist"] div[role="tab"] div', 'path':'党建及精神文明建设_', 'textFrom':'title'});
/* 培训天地 */
uba_createMask({'selector':'#item_7', 'path':'培训天地'});
uba_createMaskMultiple({'selector':'#titleContainer_7 div[role="tablist"] div[role="tab"] div', 'path':'培训天地_', 'textFrom':'title'});
/* 员工心声 */
uba_createMask({'selector':'#item_19', 'path':'员工心声'});
uba_createMask({'selector':'.employeeHeartFormSubmit', 'path':'员工心声_提交'});
/* 专题下载 */
uba_createMask({'selector':'.specialDownload', 'path':'专题下载'});
uba_createMaskMultiple({'selector':'.specialDownload li', 'path':'专题下载_', 'textFrom':'title'});
/* 友情链接 */
uba_createMask({'selector':'.friendlyLink', 'path':'友情链接'});
uba_createMaskMultiple({'selector':'.friendlyLink li', 'path':'友情链接_', 'textFrom':'title'});
/* 集团网站 */
uba_createMask({'selector':'.companyNetworks', 'path':'集团网站'});
uba_createMaskMultiple({'selector':'.companyNetworks li', 'path':'集团网站_', 'textFrom':'title'});
}
}
/* 创建遮罩区域
* selector 元素选择器
* path 所属区域
* textFrom 元素内容来自text,或者title等
*/
function uba_createMask(params) {
var targetDom = document.querySelector(params.selector);
if (targetDom == null) {
return false;
}
if (params.selectByText) {
var text = targetDom.innerText;
targetDom = targetDom.parentNode;
params.path = params.path + text;
}
/* 直接修改源代码的元素 */
targetDom.setAttribute('uba-path', params.path);
}
function uba_createMaskMultiple(params) {
var targetDomList = document.querySelectorAll(params.selector);
var num = targetDomList.length;
if (num <= 0) {
return false;
}
if (params.textFrom == 'title') {
for (var i = 0; i < num; i++) {
targetDomList[i].setAttribute('uba-path', params.path + targetDomList[i].getAttribute('title'));
}
} else {
for (var i = 0; i < num; i++) {
targetDomList[i].setAttribute('uba-path', params.path + targetDomList[i].innerText);
}
}
}
/* 获取鼠标点击所属模块 */
function uba_getModule(target){
var dom = target;
var path = dom == null ? null : dom.getAttribute('uba-path');
while (path == null && dom != document.body && dom != null) {
dom = dom.parentNode;
if (dom != null) {
path = dom.getAttribute('uba-path');
}
}
return path;
}
})();
通过将数据塞入img的src中,进行跨域:
待写....