javascripthubspot

Is there a possibility to submit a hubspot form from js?


I embedded a hubspot form in my HTML website, but I want it to be hidden as it doesn't really meet the website design. What I want is to submit that form, by clicking a regular html button. How could I do that?


Solution

  • Yes, this is indeed possible. Hubspot has a rich documentation you can make use of. I think what you are looking for is submit data for a form.

    Their form-API is REST based, meaning you communicate through sesionless HTTP requests with them. This means that you just have to call their endpoint (e.g. by using fetch()) whenever you want to submit your form.

    Since you mentioned that you don't like the form design, there is a field in their API that allows to append CSS classes to the form elements. You may want to try customizing your form with custom CSS first. (https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options)