您的当前位置:首页正文

web前端数据埋点之--友盟和百度

2024-12-01 来源:个人技术集锦

一:友盟

(1)注册友盟账号,添加站点,填写域名,填写进入链接

(2)在统计代码中复制埋点代码到js文件或者html首页,例如下:

<script type="text/javascript">
			var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
			document.write(unescape("%3Cspan id='cnzz_stat_icon_1277774388'%3E%3C/span%3E%3Cscript src='" 
			+ cnzz_protocol 
			+ "s5.cnzz.com/z_stat.php%3Fid%3D1277774388' type='text/javascript'%3E%3C/script%3E"));
			document.getElementById("cnzz_stat_icon_1277774388").style.display="none";
		</script>

(3)添加点击事件处理:

_czc.push(["_trackEvent","全麦白啤听装--立即购买","点击"]);

二:百度

(1)注册百度账号

https://tongji.baidu.com/web/10000130074/visit/toppage?siteId=14314582

(2)添加埋点,获取埋点代码,如下:

<script>
			var _hmt = _hmt || [];
			(function() {
			  var hm = document.createElement("script");
			  hm.src = "https://hm.baidu.com/hm.js?e52f8c7b1c0ba43643ebd29521f3347d";
			  var s = document.getElementsByTagName("script")[0]; 
			  s.parentNode.insertBefore(hm, s);
			})();
		</script>

(3)添加点击事件:

_hmt.push(["_trackEvent","全麦白啤听装--立即购买","点击"]);

 

显示全文