Looking through the documents for Google Tag Manager, it seems that they offer to measure the purchase by viewing confirmation pages. If I misinterpret this, it may be inaccurate due to a failure during redirection or artificial overestimation, as the link can be visited later.
So, I think it would be preferable to register or measure the purchase as soon as I receive a successful response from my POST request for the purchase. Something like that:
function purchase(data, form) {
fetchHelper(url, {
method: 'post',
body: JSON.stringify(data),
})
.then(json => {
form.reset()
window.location.href = `confirmation.html?booking=${json.booking_number}`;
})
.catch(error => {
console.error('Error: ', error)
swal('Oops', error.message, 'error');
})
}
source
share