增加友盟首页和报名页埋点

This commit is contained in:
lcc
2025-08-06 09:17:18 +08:00
parent 3a5e2dc98d
commit e5c6fbd4e4
5 changed files with 54 additions and 24 deletions
+7 -7
View File
@@ -27,13 +27,13 @@ try {
}
onMounted(() => {
// 首屏加载时发送一次PV
if (window.aplus_queue && Array.isArray(window.aplus_queue)) {
window.aplus_queue.push({
action: 'aplus.sendPV',
arguments: [{ is_auto: false }]
})
}
// 首屏加载时发送一次PV(不需要)
// if (window.aplus_queue && Array.isArray(window.aplus_queue)) {
// window.aplus_queue.push({
// action: 'aplus.sendPV',
// arguments: [{ is_auto: false }]
// })
// }
})
</script>
+15 -14
View File
@@ -104,7 +104,7 @@
>
<template v-for="(item, index) in productList" :key="index">
<div class="home-item box-shadow-darkGray inner30 mb40 ulib-r20">
<div class="item" @click.stop="pushLink(`/item/${item.id}`)">
<div class="item" @click.stop="pushLink(item)">
<div class="fn-flex">
<div class="mr20"><van-image class="imgsize-200X152" radius="10px" :src="item.banner" /></div>
<div class="fn-flex-item fn-flex fn-flex-column">
@@ -176,6 +176,7 @@ import { useUserStore } from '@/stores/user';
import api from '@/utils/api'
import { useBrandStore } from '@/stores/brand';
import { showToast } from 'vant'
import { trackEvent } from '@/utils/analytics'
const route = useRouter()
const is_first_load = ref(true)
@@ -388,6 +389,10 @@ const onSearch = () => {
showToast('请输入搜索关键字')
return
}
//友盟统计
trackEvent('search', 'CLK', {
Key_SearchKeyword: keywords.value
});
query_data.page = 1;
query_data.title = keywords.value;
finished.value = false;
@@ -400,7 +405,15 @@ const onSearch = () => {
};
// 按钮点击处理
const pushLink = (url) => {
const pushLink = (item) => {
let url = "/item/"+item.id
//友盟统计
trackEvent('list', 'CLK', {
Key_ProductId: item.id,
Key_ProductTitle: item.title,
Key_Brand: item.brandName,
Key_Series: item.seriesName
});
route.push(url);
};
@@ -530,18 +543,6 @@ const getCityBrands = async () => {
}
}
//统计代码
// const test = () => {
// const {aplus_queue} = window;
// aplus_queue.push({
// action: 'aplus.record',
// arguments: ['event_id_0', 'CLK', {
// param1: '111',
// param2: '222',
// param3: 333
// }]
// });
// }
</script>
<style lang="scss" scoped>
+12 -2
View File
@@ -81,7 +81,7 @@
</div>
<div v-else class="text-center font-28 text-color-theme">{{btn_info.tip}}</div>
<div class="pt20 ml30 mr30">
<van-button round type="danger" :disabled="btn_info.status!=1" block class="w100" @click.stop="showPop=true">{{btn_info.text}}</van-button>
<van-button round type="danger" :disabled="btn_info.status!=1" block class="w100" @click.stop="showEnrollPop">{{btn_info.text}}</van-button>
</div>
</div>
</div>
@@ -105,6 +105,7 @@ import { ref, onMounted, watch } from 'vue'
import { useRoute } from 'vue-router'
import api from '@/utils/api'
import { trackEvent } from '@/utils/analytics'
import CouponItem from '@/components/CouponItem.vue'
import PopGetAllowance from '@/components/PopGetAllowance.vue'
import PopStores from '@/components/PopStores.vue'
@@ -283,7 +284,16 @@ const showStorePop = ref(false)
function handleShowStorePop(val) {
showStorePop.value = val
}
function showEnrollPop(){
//友盟统计
trackEvent('coupon', 'CLK', {
Key_CouponId: productDetail.value.coupons.coupon_id,
Key_CouponName: productDetail.value.coupons.title,
Key_Brand: productDetail.value.brandName,
Key_Series: productDetail.value.seriesName
});
showPop.value=true
}
</script>
<style scoped>
+1 -1
View File
@@ -26,7 +26,7 @@ const router = createRouter({ history: createWebHistory(), routes })
// 路由跳转后发送PV统计
router.afterEach(() => {
// 检查全局的aplus_queue是否存在
if (window.aplus_queue && Array.isArray(window.aplus_queue)) {
if (window.aplus_queue) {
// 使用提供的PV发送事件,按要求传递参数
window.aplus_queue.push({
action: 'aplus.sendPV',
+19
View File
@@ -0,0 +1,19 @@
/**
* 友盟埋点统计
* @param {string} eventName - 事件名称
* @param {string} eventType - 事件类型,如 'CLK'(点击), 'EXP'(曝光) 等
* @param {Object} params - 事件参数
*/
export const trackEvent = (eventName, eventType = 'CLK', params = {}) => {
// 确保 aplus_queue 存在
if (typeof window !== 'undefined' && window.aplus_queue) {
console.log("友盟埋点统计");
console.log(eventName,eventType,params);
window.aplus_queue.push({
action: 'aplus.record',
arguments: [eventName, eventType, params]
});
} else {
console.error('aplus_queue is not available');
}
};