友盟
官网直达地址
这里拿的是h5的案列说明
账号密码首先先登录上去
埋点
第一步
引入这个就是统计了 可以开启埋点之旅了
index.html
<script>
(function(w, d, s, q, i) {
w[q] = w[q] || [];
var f = d.getElementsByTagName(s)[0],j = d.createElement(s);
j.async = true;
j.id = 'beacon-aplus';
j.src = 'https://d.alicdn.com/alilog/mlog/aplus/' + i + '.js';
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'aplus_queue', '203467608');
//集成应用的appKey
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['appKey', 'xxxxxxx']
});
/************************以下内容为可选配置内容****************************/
//sdk提供手动pv发送机制,启用手动pv(即关闭自动pv),需设置aplus-waiting=MAN;
//注意:由于单页面路由改变时不会刷新页面,无法自动发送pv,所以对于单页应用,强烈建议您关闭自动PV, 手动控制PV事件的发送时机N": N取值为300-3000之间的整数值 , 所有日志指令在SDK初始化完成后的N毫秒内将被hold在指令队列, 直至N毫秒等待结束;"MAN": 取消自动化PV日志采集. 设置为MAN之后, 所有PV日志均需手动触发, 但其他类型的事件日志不受影响
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['aplus-waiting', 'MAN']//是手动需要上报sendPv
});
//是否开启调试模式
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['DEBUG', true]
});
//是否指定用作计算umid的id类型,默认为cnaid,目前支持:
//1. 微信\QQ openid, 字节、百度 anonymousid, 支付宝 alipay_id
//2. 微信、QQ、字节、百度平台的 unionid
//3. 业务方自己生成的随机id uuid
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['aplus-idtype', 'xxxx'] //取值参考见附表1
});
//设置userid
aplus_queue.push({
action: 'aplus.setMetaInfo',
arguments: ['_user_id', 'xxxx'] //值为业务自定义的登录账号ID
});
</script>
第二步
上报时机 (异步/同步)获取用户的个人信息(id/用户名)
一般在HTML的js里面使用DOMContentLoaded事件
常适用于smk md的获取用户信息(ym md上报时机请求用户信息) (smk ym 的md)可在这里面写入
<script>
//写入方法
function 自定义方法名(){
}
// DOMContentLoaded事件
document.addEventListener('DOMContentLoaded', function () {
自定义方法名();
}, false);
</script>
<script>
//这一步也在HTML里面获取信息写入方法
//写入方法 这里得到ym的用户信息
function 自定义方法名(){
}
// DOMContentLoaded事件
document.addEventListener('DOMContentLoaded', function () {
自定义方法名();
}, false);
</script>
第三步
这个相当于曝光
发送
在需要埋的页面进行写sendPV
created(){
const {aplus_queue} = window;
// 一个简单的demo
aplus_queue.push({
'action':'aplus.sendPV',
'arguments':[{
is_auto: false
}, {
//必传参数
ts: 1612336857529, //当前时间戳
path: "yourCurrentPagePath", //当前page的url
page_name: "yourCurrentPageName", //您当前页面的自定义页面编码
duration: '111111', // 手动pv,duration信息需要您自己计算
// 自定义PV参数key-value键值对
x: 111,
y: 222
}]
});
}
点击埋点来咯
CLK 点击事件埋点
EXP//曝光
CLK //点击
const {aplus_queue} = window;
aplus_queue.push({
'action':'aplus.record',
'arguments':['/pages.index.index.clkOnce', 'CLK', {
x: '111',
y: '222',
z: 333,
page_name: "demoPageName", //您当前页面的自定义页面编码
}]
});
提示app更新安装
效果图
代码
当更新软件时,可以提示用户更新下载,如果没有可以提示浏览器打开下载
下面以vue的为案列
官网案列
<scriptsrc="https://g.alicdn.com/jssdk/u-link/index.min.js"></script>
<script>
ULink.start({
id:"xxx",
data:{
a:4,
b:'xx
},
}).ready(function(ctx){
console.log(ctx.solution);// --> ISolutions;
ctx.wakeup();
});
</script>
引入案列
一般在生产文件cli的时候会有一个文件
然后把官网的引入路径放在这个文件
然后创建一个文件
这里只是参考放在哪个位置---------具体以实际开发为列
<template>
<div class="main" @touchmove.prevent @mousewheel.prevent>
<img src="../../assets/img/down.png" alt="" />
<button id="xxl">下载</button>
</div>
</template>
<script>
import { getUrlString } from "@/utils";
export default {
data() {
return {
um_chnnl: getUrlString("um_chnnl"),
};
},
mounted() {
window.ULink([
{
id: "usr1bm6lefckiamn",
data: {
// um_chnnl: this.um_chnnl,
umeng_channel: this.um_chnnl,
},
selector: "#xxl",
auto: true,
timeout: 2000,
lazy: false,
useOpenInBrowerTips: function (ctx) {
//提示浏览器打开 带遮罩层demo
return `<div style="position:fixed;left:0;top:0;background:rgba(255,0,255,0.5);width:100%;height:100%;z-index:19910324;"></div>`;
},
proxyOpenDownload: function (defaultAction, LinkInstance) {
console.log(defaultAction);
if (LinkInstance.solution.type === "scheme") {
// qq或者微信环境特殊处理下
if (ULink.isWechat || ULink.isQQ) {
// 在qq或者微信环境执行内置逻辑,具体内置逻辑为:当设置了useOpenInBrowerTips字段时,qq&&微信&&scheme时,启用蒙层提示去浏览器打开
defaultAction();
} else {
window.location.href = LinkInstance.solution.downloadUrl;
}
} else if (LinkInstance.solution.type === "universalLink") {
}
},
},
]);
},
};
</script>
<style scoped>
.main {
width: 100%;
height: 100vh;
position: relative;
}
img {
width: 100%;
height: 100%;
z-index: -1;
position: absolute;
top: 0;
left: 0;
}
#xxl {
z-index: 1000;
width: 140px;
height: 45px;
line-height: 45px;
background: rgba(255, 255, 255, 0.1);
border: 2px solid #ffffff;
border-radius: 20px;
font-size: 16px;
position: absolute;
bottom: 100px;
left: 33%;
margin: 0 auto;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: center;
color: #ffffff;
}
</style>