I'm having a VueJS application where a user submits a form. Data is sent to the server using Vue-resource. I need to tell Google that this is a conversion.
What Google gives me is a script where told me to put in 'thanks.html' or some page like that. My VueJS application is a single page application. So what should I do? Where should I put the code?
VueJS code for submitting the form:
methods: {
submit() {
this.$http.post(store.state.url+'api/submit_quote.php', {
formData: this.formData
})
.then(response => {
this.submitted = true
});
}
}
You can use a google analytics tracking event inside the .then as:
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');
});
}
}
You can then set up a goal in Google Analytics for the event, this goal can then be shared back to AdWords.
For more details see: https://developers.google.com/analytics/devguides/collection/analyticsjs/events