如何在 VueJS 中跟踪 Google Analytics/Adwords 转化
How to track Google Analytics/ Adwords Conversions in VueJS
我有一个 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 分析跟踪事件:
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
我有一个 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 分析跟踪事件:
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