【问题标题】:How to track Google Analytics/ Adwords Conversions in VueJS如何在 VueJS 中跟踪 Google Analytics/Adwords 转化
【发布时间】:2017-02-16 06:10:56
【问题描述】:

我有一个用户提交表单的 VueJS 应用程序。使用 Vue 资源将数据发送到服务器。我需要告诉谷歌这是一次转换。

Google 给我的是一个脚本,告诉我输入“thanks.html”或类似的页面。我的 VueJS 应用程序是一个单页应用程序。所以我该怎么做?我应该把代码放在哪里?

提交表单的VueJS代码:

methods: {
  submit() {
    this.$http.post(store.state.url+'api/submit_quote.php', {
        formData: this.formData
    })
    .then(response => {
      this.submitted = true
    });
  }
}

【问题讨论】:

  • 您可以将单页应用程序上的路由传递给 google 脚本吗?例如:www.mysite.com 是您的 SPA,而您将 www.mysite.com/thanks 传递给 google 脚本?
  • 我能做到。但是现在做起来有点费时!这就是为什么。但如果我能做到呢?我可以把那个代码放在哪里?
  • 也分享你从google收到的代码,然后我可以添加答案,设置路由器非常简单。应该不会花太多时间。
  • 你应该能够在你的 vue 函数中包含正确的谷歌代码

标签: google-analytics vue.js google-ads-api vuejs2 vue-resource


【解决方案1】:

您可以在 .then 中使用谷歌分析跟踪事件:

  methods: {
  submit() {
    this.$http.post(store.state.url+'api/submit_quote.php', {
        formData: this.formData
    })
    .then(response => {
      this.submitted = true
      ga('send', 'event', 'some-goal', 'success');
    });
  }
}

然后,您可以在 Google Analytics(分析)中为活动设置一个目标,然后可以将该目标共享回 AdWords。

更多详情见:https://developers.google.com/analytics/devguides/collection/analyticsjs/events

【讨论】:

  • 我认为这也可以。我使用的是 goog_report_conversion('quotzap.com/get-quote') 及其工作! (用于 AdWords 转化跟踪)
猜你喜欢
  • 1970-01-01
  • 2011-01-06
  • 2015-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-30
  • 2014-07-26
  • 1970-01-01
相关资源
最近更新 更多