@oasis-games/front-analytics-plug
v1.0.3
Published
Simple design for third-party time measurement tools.
Keywords
Readme
front-analytics-plug
Simple design for third-party time measurement tools.
Building manually
npm install @oasis-games/front-analytics-plugExample Usage In Vue Project
Vue App.vue component:
<template>
<div>
<router-view></router-view>
</div>
</template>
<script>
import {
googleAns,
googleAds,
facebookAds,
tikTokAds
} from '@oasis-games/front-analytics-plug';
export default {
name: '',
data() {
return {};
},
computed: {},
watch: {},
methods: {},
mounted() {
googleAns('UA-161928518-11');
switch (this.$route.query.utm_source) {
case 'google':
googleAds('AW-10788263820');
break;
case 'facebook':
facebookAds('6218909814845992','https://api-cstp.vermi-succotash.net','msnken'); //id 接口域名 gameCode
break;
case 'tiktok':
tikTokAds('C5RSQDC247C0IGAK3JKG');
break;
}
}
};
</script>Vue test.vue child-component:
<template>
<div>
<button @click="testGa">test</button>
</div>
</template>
<script>
export default {
name: '',
data() {
return {};
},
computed: {},
watch: {},
methods: {
testGa() {
window.ga('send', 'event', 'testga', 'click', 'PC');
switch (this.$route.query.utm_source) {
case 'google':
window.gtag('event', 'conversion', {
send_to: 'AW-10788263820/X9TaCPTs3_sCEIyvn5go' //AW-10788263820/X9TaCPTs3_sCEIyvn5go
});
break;
case 'facebook':
window.fbq('track', 'CompleteRegistration'); //CompleteRegistration
window.fbAds('https://api-cstp.vermi-succotash.net','CompleteRegistration','msnken') //接口域名 事件名 gameCode
break;
}
}
}
};
</script>
<style scoped>
</style>Methods
| 属性 | 类型 | 说明 | 参数 | 自定义事件上报 | | :---------- | :------- | :-------------- | :------------ | :------------- | | googleAns | function | GA 打点 | 事件 ID(必传) | window.ga() | | googleAds | function | Google 广告打点 | 事件 ID(必传) | window.gtag() | | facebookAds | function | Facebook 打点 | 事件 ID(必传) | window.fbq() window.fbAds() | | tikTokAds | function | TikTok 打点 | 事件 ID(必传) | - |
自定义事件上报参数,详见飞书打点文档
