友盟是阿里巴巴旗下的一个用户行为统计工具,官方网址为 https://www.umeng.com/
该文章主要描述友盟工具在web端()的实施使用,工作原理,相关源码分析,以及功能分析.
实施使用
1.在友盟中的域名列表中配置好要统计的域名
- 在自己网站的HTML页面中嵌入以下友盟提供的跟踪代码:
工作原理
跟踪代码请求 JS文件 http://s4.cnzz.com/z_stat.php?id=1278216955 (源码分析区域有完整的代码)
该JS文件为友盟主要文件里面透出 push 方法:
e = window
p() { this.c = “1278216955”; this.ca = “z”; this.Y = “”; this.V = “”; this.X = “”; this.D = “1574231684”; this.$ = “z3.cnzz.com”; this.W = “”;
this.H = “CNZZDATA” + this.c; this.G = “CNZZDbridge” + this.c; this.O = “_cnzz_CV” + this.c; this.P = “CZ_UUID” + this.c;
this.K = “UM_distinctid”; this.A = “0”; this.J = {}; this.a = {}; this.Ca() }
Ca: function () { try { this.ma(), this.ja(), this.ha(), this.U(), this.ya(), this.S(), this.Ba(), this.w(), this.wa(), this.va(), this.za(), this.o(), this.ua(),
this.xa(), this.Aa(), this.sa(), this.qa(), this.ta(), this.Ga(), e[this.G] = e[this.G] || {}, this.ra("_cnzz_CV") } catch (a) { h(a, “i failed”) } },
Ga: function () { try { if (“undefined” === typeof e._cz_account || e._cz_account === this.c) { e._cz_account = this.c;
if ("[object Array]" === {}.toString.call(e._czc)) for (var a = e._czc, b = 0, c = a.length; b < c; b++)this.L(a[b]); this.Ea() } } catch (d) { h(d, “pP failed”) } },
Ea: function () { try { var a = this; e._czc = { push: function () { return a.L.apply(a, arguments) } } } catch (b) { h(b, “oP failed”) } },
L 方法中包含循环识别如下方法:
_trackPageview
case "_trackPageview": if (a[1]) {
this.a.f = q + "//" + e.location.host; "/" !== a[1].charAt(0) && (this.a.f += "/"); this.a.f += a[1];
if ("" === a[2]) this.a.g = "";
else if (a[2]) {
var b = a[2]; "http" !==
b.substr(0, 4) && (b = q + "//" + e.location.host, "/" !== a[2].charAt(0) && (b &#