埋点介绍
埋点就是收集页面的浏览的记录,例如点击某个按钮的次数,搜索某个关键字的次数等
神策数据介绍
demo
<script>
(function(para) {
var p = para.sdk_url, n = para.name, w = window, d = document, s = 'script',x = null,y = null;
w['sensorsDataAnalytic201505'] = n;
w[n] = w[n] || function(a) {return function() {(w[n]._q = w[n]._q || []).push([a, arguments]);}};
var ifs = ['track','quick','register','registerPage','registerOnce','clearAllRegister','trackSignup', 'trackAbtest', 'setProfile','setOnceProfile','appendProfile', 'incrementProfile', 'deleteProfile', 'unsetProfile', 'identify','login','logout','trackLink','clearAllRegister'];
for (var i = 0; i < ifs.length; i++) {
w[n][ifs[i]] = w[n].call(null, ifs[i]);
}
if (!w[n]._t) {
x = d.createElement(s), y = d.getElementsByTagName(s)[0];
x.async = 1;
x.src = p;
y.parentNode.insertBefore(x, y);
w[n].para = para;
}
})({
sdk_url: '在 github 下载新版本的 sensorsdata.min.js ',
name: 'sa',
//配置打通 App 与 H5 的参数
use_app_track: true,
server_url:'数据接收地址'
});
sa.quick('autoTrack'); //神策系统必须是1.4最新版及以上
</script>
//如果app_info返回null,则APP与H5之间没有打通
sensors.getAppStatus((app_info) => {
window.DISTINNCT_ID = app_info.distinct_id
})
function mdEvent(eventName,params){
var defaultParams = {
属性值。。。。。
}
sensors.identify(window.DISTINNCT_ID);//获取的用户信息 id
sensors.quick('autoTrack');
sensors.track(eventName, Object.assign(defaultParams ,params));
}
调用 假设触发埋点事件的按钮 id 为 submitBtn, $(’#submitButton’).click(function(){ maiEvent(“事件命名”,{action_type: “1”}) });