0.0.3 • Published 2 years ago

ga-mp-tracker v0.0.3

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

在小程序中使用谷歌统计4

1.安装

npm i ga-mp-tracker

2.设置全局实例

import gaTracker from 'ga-mp-tracker'
const { GoogleAnalytics } = gaTracker
const ga = new GoogleAnalytics({
  measurement_id: 'xxx',
  api_secret: 'xxx'
})
Vue.prototype.$ga = ga

3.发送页面事件

const { Event } = gaTracker
const event = new Event('page_view', {
page_title: '页面标题'
})
this.$ga.send(event)

4.发送自定义事件

const { Event } = gaTracker
const event = new Event('event_name', params)
this.$ga.send(event)