vue单页应用里如何使用2个友盟/cnzz账号

产品经理的需求是某些路由使用友盟 A账号跟踪, 某些路由使用友盟 B账号跟踪
项目是vue单页应用, 已经关闭自动追踪, 根据路由设置账号手动跟踪

index.html

<script type="text/javascript">
  /*统计代码*/var _czc = _czc || [];_czc.push(["_setAutoPageView", false]);
</script>
<body>

App.vue

watch: {
  '$route'() {
    //判断路由
    if(/.../.test(this.$route.path)) {
      _czc.push(["_setAccount", siteIdA])
    } else {
      _czc.push(["_setAccount", siteIdB])
    }

    let location = window.location
    let content_url = location.pathname + location.hash
    let referer_url = '/'
    _czc.push(['_trackPageview', content_url, referer_url])
  }
}

现在看友盟后台数据, AB的账号都有对方的页面路径, 求教2个账号应该怎么写

阅读 1.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题