Hello All,
We use the “hsvalidatedsubmit” event in conjunction with a window.location.refresh call in order to display different thank-you pages, based on an option from the submitted form.
In some instances, I get the impression this custom redirect is preventing the creation of the Contact in the HubSpot account. Does this make sense at all? Has anyone experienced similar issues when using hsvalidatedsubmit?
$('body').on('hsvalidatedsubmit', '.hs-form', function (e) {
if ($(this).hasClass('#########')) {
/*evaluate use case here */
if something {
window.location.href = "url1";
}
else if somethingelse {
window.location.href = "url2";
}
};
}
Also, is there a way to call a custom callback function once the hsvalidatedsubmit has completed successfully?
Thanks a bunch!
DL
Hey @danielelodola , unsure if you have seen this forms doc before. There is a callback for onformsubmitted that might be of value.
@Kevin-C , what are your thoughts?
Thanks @dennisedson
Hey @danielelodola
I believe Dennis is correct!
Using onformsubmitted will ensure that the coversion will resolve before the page redirects!
Thanks @Kevin-C @dennisedson
Does the “onformsubmitted” method replace the “hsvalidatedsubmit” method? Does it ensure that the callback function(s) are only on triggered on valid form submissions?
This aspect is important for us, as we like to handle all conversion tracking at the valid form submission level.
Regards
DL
Hey @danielelodola
"The hsvalidatedsubmit event is triggered after the data in a HubSpot form passes validation. You can detect when that event is triggered, but anything you do after detecting the event would not block the submission from proceeding.
The onFormSubmit function gets executed as part of the submission itself, so anything you include in that function will be executed before the form proceeds with the submission.
…
onFormSubmit is called after validation passes, right before the form data is actually sent to HubSpot, and if you can add onFormSubmit to the embed code it’s going to be a better solution than listening for the hsvalidatedsubmit event."
From this post
@Dadams could you lend a hand clarifying? I’m sure I’ve butchered something lol