@zaobao/analytics
v1.0.6
Published
zaobao data collection and analytics
Downloads
2
Readme
Usage
<!-- Start Zaobao CN Analytics -->
<script>
(function (r,c,u,p,t,a,m) {
r.ctag=r.ctag||function(){(r.ctag.q=r.ctag.q||[]).push(arguments)};r.ctag.ad=t;
a=c.getElementsByTagName('head')[0];m=c.createElement('script');m.async=true;
m.src=u+'?'+p;a.appendChild(m);
})(window,document,"../dist/ctag.js","id=you id&secret_key= you secret&api_host=you api_host")
</script>
<!-- End Zaobao CN Analytics -->
<script>
//如果scr脚本未携带key,则需要手动创建实例
//手动创建带参
ctag("create","you key","you secret",{
stay_duration: false,
screen_view: true,
exception_report: false,
disable: false,
});
// //配置命令
ctag("config",{
stay_duration:false,
screen_view:false
})
ctag("config",{
stay_duration:false,
screen_view:false,
exception_report:true,
disable:true
})
// //获取指纹
ctag('get',"clientId",console.log);
// //获取网页基础信息
ctag('get',"measurement",console.log);
// //获取配置
ctag('get',"config",console.log)//
// //获取实例,最后个参数不传,则使用默认实例(第一个)
ctag('get',"instance",console.log,"you key")//
// //获取实例,最后个参数不传,则使用默认实例(第一个)
ctag('get',"instance",console.log)//
// //获取插件实例
ctag('get',"plugin",console.log,"measurement")//
// //移除实例
ctag('remove',"instance.you key",console.log)
// //发送screen_view埋点
ctag('send',"screen_view",{
page:"home",
screenId:'124'
},"you key")
//设置全局参数
ctag("set","global",{
// api_host:"http://172.16.20.79:8080/cg.gif",
// api_host:"http://172.16.20.75:5000",
user_id:"userid",
api_version:"1.3.0",
});
//获取全局参数
ctag('get',"ssid",(e)=>{
console.log("11",e.toString())
})//
ctag('get',"shunt",(e)=>{
console.log("11",e)
},"condition_x")//
ctag('get',"globalConfig",console.log)//
ctag('get',"sessionId",console.log)//
//设置页面信息
ctag("set","auto",{
nihao:"5555"
});
ctag('get',"measurement",console.log)
ctag("get","automaticallyData",console.log);
ctag('send',"screen_view",{
page_name:"home",
screen_id:'124',
scene_id:"第三方身份"
})
//初始化完成回调
ctag((ctx)=>{
console.log("ready")
// n.a()
console.log(ctx)
})
ctag("plugin","duration:stay",(value)=>{
console.log(value)
ctag('send','duration',{
scene_id:"news_detail",
item_id:'',
recommend_id:""
})
})
</script>
plugin
曝光埋点
<script>
ctag('plugin',"exposure:observe",document.getElementById("d1"),(intersection,stop)=>{
if(intersection){
ctag("send","event",{
event_name:"",// 事件名称
event_category:"曝光",//事件类别
event_label:"中国发展高科技",//事件标签
event_action:"exposure",//事件动作
event_value:0,
experiment_id:2,
variant_id:4
})
stop()
}
});
</script>
停留时长
<script>
ctag("plugin","duration:stay",(value)=>{
ctag('send','duration',{
scene_id:"news_detail",
item_id:'121',
stay:value
})
})
</script>
插件注册
<script>
class PluginInspector {
static NAME = "inspector";
version = "1.0.0";
constructor(options) {
console.log(options)
}
run(c){
console.log(c)
console.log('run')
}
}
ctag("install",PluginInspector,{a:1});
ctag("plugin","inspector:run",true);
</script>