Hubspot Form Not Redirecting To URL

Hello,

I recently set up a hubspot form which I embed on my website using the provided html code. When the form is set to display a “thank you” message once a user hits submit, it works fine - the form is submitted and the “thank you” message is displayed.

If I instead configure the form to forward the user to a URL once they submit the form, the process breaks. Specifically, the user his “submit” and nothing happens. No redirect. It’s as if the page just freezes. I do recieve the submission, so it’s something specific to the redirect that is not working.

The site I’d like the form to redirect to is https://www.sugarmommascookies.com/order-form-ty - I’ve confirmed this link is active, and that is is typed exactly as is in the form option to redirect as shown below:

I’m not that technical, but in using Chrome’s Developer tools, I see the following error appear in the Chrome Consol when a user hits submit:

These errors do not appear when the form is set to just display a “thank you message”

I feel as though this has to be a simple problem, but I’ve not been able to find an answer that works in the current threads.

Appreciate anyone’s help!

Hi @GFusco

Thank you for reaching out.

Would you mind sharing the page on which your form can be found?

I also want to tag some of our experts on this - @tjoyce @thesnappingdog do you have any thoughts for @GFusco on this?

Thank you!

Best

Tiphaine

Hi Tiphaine,

Thanks so much for the response. The site would be www.sugarmommascookies.com/order-form - You can fill out and submit the form on there, but you will notice that it seems to just freeze if you hit submit.

Ok, this one is tough to explain and probably even tougher to fix.

Godaddy builder does some insane things to code and this is no exception.

Your hubspot form is in an iframe and when you submit the form, the embed code tells the parent of the iframe (which would be your browser window that encompasses your whole webpage including the iframe) to redirect to a different page… however, since godaddy is putting your form (iframe) inside of another iframe, when the form submits, it’s telling the parent 1 iframe instead of the parent of the parent (parent #2) of the iframe, to do the redirect.

Somehow, you need to tell the builder (Not Hubspot) to NOT render this form in an iframe.

(It’s iframe inception :slightly_smiling_face: )

Hope this makes sense

Hi there! Just wanted to thank you for your detailed explanation. i’m still debating my options to solve it, but your help at least helped me understand the issue. Thank you!

Hi, this is what is happening but what is the solution? Do I need to speak to our developer agency to fix?

Our issue was with wix, the form submitted but the thank you page was embedded in an embedded iframe. we had to add an onFormSubmit Handler to target the top window object for the redirect:

hbspt.forms.create({
 portalId: '9359588',
 formId: '7b343168-ac08-4643-a5cd-568df91c6824',
 onFormSubmit: function($form){
 window.top.location = "http://www.yoururl.com";
 }
});

Thanks for sharing, @jbriccetti1 :blush:

Best,

Diana

Dear @jbriccetti1 ,

thanks for your code! I edited the portalID, formID and my url to match the form code I got from Hubspot. I added to WIX as custom code in the body of the respective page (and tried as well to add it to the header). But the thank you page is still showing in the iframe. Am I putting the code to the wrong place?
Help would be much appreciated!

Hi @GFusco :slightly_smiling_face:

As I can see, it seems that there is a problem with the way you embedded the form. I checked the page HTML source code and I saw a form inside another form.

Can you share the embed code you used to publish the form?

Thanks,

Rafael López

Hi Rafael!

I really appreciate the response. That sounds in line with something I read about “a frame being within a frame” and that not being allowed to be redirected for security reasons. I’d be really interested in your thoughts on the code below:

<script charset=“utf-8” type=“text/javascript” src=“//js.hsforms.net/forms/shell.js”></script>
<script>
hbspt.forms.create({
portalId: “14504658”,
formId: “99382c3b-8443-4b81-8d78-796767730516”
});
</script>

Hi @GFusco :slightly_smiling_face:

Thank you for your response. I think that your embed code is ok. I recommend you to follow @tjoyce iframe’s theory.

Regards,

Rafael López

I have the exact same problem. Trying to redirect my embedded form after submit. I actually created a CodePen to try and get it resolved (to no avail): https://codepen.io/antonylyfta/pen/NWwEZLM

My form submits (I receive the submission), but the page does not redirect (INCEPTION!).

Here’s my error message: Upload and share screenshots and images - print screen online | Snipboard.io

It would be really great for the Community if somebody could find a (least bad) solution to this problem. I am eager to use HubSpot forms - but without additional control over the data my options are severely limited.

Who can save the day?

Hi @GFusco, I’m encountering the exact same issue on Wix as my contact form is embedded in an iFrame and therefore the thank you page I’d like to redirect to (for tracking purposes) is only loaded within the frame.

Did you ever happen to find a workaround?

Thank you!

Hey I ran into the same issue and this is the fixed form I had just put your embed code into chatgpt and ask it to turn yours into the same as mine.
<script charset=“utf-8” type=“text/javascript” src=“//js-na2.hsforms.net/forms/embed/v2.js”></script>
<script>
hbspt.forms.create({
portalId: “242003643”,
formId: “6f55d8b5-9a79-42e8-85ca-2b3a1ba6a4a7”,
region: “na2”,
onFormSubmitted: function($form) {
window.top.location.href = “https://tradeaid.io/video”;
}
});
</script>