When I fill in credit card info and submit the payment on the live website, the transition is so fast that it does not let the purchase events execute entirely and redirect to next page. I need to stop the redirection for a while and then, after a pause, redirect user to the thank you page.
I am looking for something eg:
e.preventDefault()
var redirectURL = e.redirectURL ( this is assumption )
Note: I don't have backed access so I am using GTM to execute my scripts.
You can add onsubmit event to your form element, and then add your logic to that event.
function onSubmit() {
//TODO: Add your other logic here
alert("The form was submitted");
}
<!DOCTYPE html>
<html>
<body>
<p>When you submit the form, a function is triggered which alerts some text.</p>
<form action="/" onsubmit="onSubmit()">
<input type="submit" value="Submit">
</form>
</body>
</html>