google-analytics - 如何在 VueJS 中跟踪 Google Analytics/Adwords 转化

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

我有一个 VueJS 应用程序,用户在其中提交表单。使用 Vue-resource 将数据发送到服务器。我需要告诉 Google 这是一次转换。

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
    });
  }
}

最佳答案

您可以在 .then 中使用 Google Analytics 跟踪事件,如下所示:

  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

关于google-analytics - 如何在 VueJS 中跟踪 Google Analytics/Adwords 转化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42266233/

相关文章:

javascript - SoundManager2 onplay 事件配置不起作用

google-analytics - 是否可以使用 HTML5 音频标签属性 ID 来跟踪 Google Anaylitics 中的歌曲播放

database - 在 config.ru 中使用变量(数据库请求)

php - 获取 Google 的全局每月搜索量

javascript - 如何跟踪 Google Adwords 的点击转化?

r - 将 Adwords 流量估算器服务与 R/‘RAdwords’ 包结合使用

google-analytics - 按用户 ID 查询 Google Analytics

javascript - 使用 VueJS 更新对象中的多个 Prop 时如何引起 react ?

vue.js - Vue-Multiselect Multiple Select 能够重新选择选中的项目

javascript - 组件内 Navigation Guard 回调不起作用 : Nuxt JS and `beforeRouteEnter`