我有一个 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/