sd-track-event

PV,UV,事件处理

Usage no npm install needed!

<script type="module">
  import sdTrackEvent from 'https://cdn.skypack.dev/sd-track-event';
</script>

README

sd-track-event


安装使用


  npm install sd-track-event --save
  Vue.use(sdTrackEvent, {
    biz: 'cf', //cf, hz, sdb
    selfTag: storage.get('uuid')
    authorizationV2: xxx
  })

  切换路由使用:
  /*
    page_enter 页面访问事件
    click 单点击事件 用户单击某按钮或其他页面元素
    share 分享事件 分享动作发生时
    input 输入事件 用户在页面输入内容时
    api 接口调用事件
    swipe 滑动事件 手指在屏幕上滑动时会触发
    dialog 弹窗事件
    test 执行ABtest的操作打点
  */
  this.$sdTrackEvent.send({
    op: 'page_enter',
    fromPath: from.fullPath,
    subChannel: '',// 子渠道
    toPath: to.fullPath,
    pageName: to.name,// 页面名字
    channel: to.query.channel,
    testCode: to.query.grayMode,
    extInfo: {
      case_id: to.params.infoUuid || to.query.infoUuid
    }
  })

  点击事件绑定:
  <div v-sd-track="'ID'" data-test-flag="2" data-ext-info-test_test="test" .....></div>

  新增方法:
  // 获取上家用户的加密userid
  this.$sdTrackEvent.getUserSourceId()

  // 获取上家的分享ID
  this.$sdTrackEvent.getShareId()

  // 获取自己本次分享的Id
  this.$sdTrackEvent.getSelfShareId()

  // 生成分享链接所需要的参数并返回 如:userSourceId, shareId
  url = this.$sdTrackEvent.setShareParams(url) // www.shuidichou.com/cf/launch?userSourceId=xxxx&shareId=xxxx

Options

  selfTag: '',// 用户唯一标识
  biz: '',// 业务标识
  authorizationV2: '',// 登录票
  channel: '',// 渠道
  elementCode: '',// 事件ID
  testCode: '',// ABTEST标识
  platform: 'wx',// 什么平台
  subChannel: '',// 子渠道
  fromPath: '',// 从哪来
  toPath: '',// 到哪去
  extInfo: ''// 自定义字段