CMS Development

CLahnsteiner
Member

Javascript with Hubspot forms

SOLVE

Hi!

 

I added a hubspot form with two input fields (email and code). After pressing a button, a small JavaScript file should be executed that generates a URL using the input values (e.g. https://example.com?email={entered_email}&code={entered_code}) and should redirect the user to this generated URL. Any ideas how I can aAdd a javascipt file to that form?

 

Many thanks,

Cornelia

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Javascript with Hubspot forms

SOLVE

Hi @CLahnsteiner ,

 

You could customize the embed form where you can write your logic in the `onFormSubmit` event. That way, you can capture the input values and write a simple script to redirect the user to a new page. Make sure to use an inline thank you message for the form to prevent the user being redirected by HubSpot. 

 

Here is a great example from another post: https://community.hubspot.com/t5/Tips-Tricks-Best-Practices/Form-redirect-based-on-property-selectio...

However, if you have content or marketing Hub Pro, there is also a beta available that might allow you to set this up without having to code this: https://knowledge.hubspot.com/forms/create-and-edit-forms-using-the-new-form-editor



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

2 Replies 2
Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Javascript with Hubspot forms

SOLVE

Hi @CLahnsteiner ,

 

You could customize the embed form where you can write your logic in the `onFormSubmit` event. That way, you can capture the input values and write a simple script to redirect the user to a new page. Make sure to use an inline thank you message for the form to prevent the user being redirected by HubSpot. 

 

Here is a great example from another post: https://community.hubspot.com/t5/Tips-Tricks-Best-Practices/Form-redirect-based-on-property-selectio...

However, if you have content or marketing Hub Pro, there is also a beta available that might allow you to set this up without having to code this: https://knowledge.hubspot.com/forms/create-and-edit-forms-using-the-new-form-editor



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


AddaxLab
Member

Javascript with Hubspot forms

SOLVE

You can add automation after the form is submitted (and a contact is created). In this new workflow, you can send a webhook to your URL. Here, you can choose the request method (GET or POST) and add the needed fields from the new contact. 
But, as I right remember, you should have OperationalHub for that. 

 

AddaxLab_0-1726836849150.png

 

AddaxLab_1-1726837190531.png