1.0.0 • Published 2 years ago

@lx1084974046/package01 v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

front-analytics-plug

Simple design for third-party time measurement tools.

Building manually

npm install @lx1084974046/package01

Example Usage In Vue Project

Vue App.vue component:
<template>
  <div>
    <router-view></router-view>
  </div>
</template>

<script>
import {
  googleAns,
  googleAds,
  facebookAds,
  tikTokAds
} from '@lx1084974046/package01';
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');
        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
          break;
      }
    }
  }
};
</script>

<style scoped>
</style>

Methods

属性类型说明参数
googleAnsfunctionGA打点事件ID(必传)
googleAdsfunctionGoogle广告打点事件ID(必传)
facebookAdsfunctionFacebook打点事件ID(必传)
tikTokAdsfunctionTikTok打点事件ID(必传)
1.0.0

2 years ago