1、注册账号
https://web.umeng.com/main.php?c=user&a=index
2、添加站点
https://web.umeng.com/main.php?c=site&a=add&siteid=1273820405
3、部署代码
mounted() {
this.initCNZZ();
},
methods: {
initCNZZ() {
//添加脚本
const script = document.createElement('script');
script.src = 'https://s22.cnzz.com/z_stat.php?id=1273820405&web_id=1273820405';
script.language = 'JavaScript';
script.id='cnzz';
document.body.appendChild(script);
}
},
watch: {
'$route' () {
if (window._czc) {
//监听路由变化
let location = window.location;
let contentUrl = location.pathname + location.hash;
let refererUrl = '/';
window._czc.push(['_trackPageview', contentUrl, refererUrl])
}
}
}
4、监听事件
api:http://open.cnzz.com/a/api/trackevent/
cnzzEvent:function(category,action,label,value,nodeid){//cnzz事件统计
if (window._czc) {
czc.push(['_trackEvent',category,action,label,value,nodeid]);
}
}