Submitting form data to HubSpot

forms

#1

Hey everyone,

I’m new to Hubspot and have a question about submitting and saving form data from my website. I am currently building a React.js application that includes a simple contact form asking for a user’s name and email address. When a user submits the form, I want to use AJAX to send and save the user info from the form to my Hubspot portal (I am using the free tools, which might affect the features I’m able to access?). Basically I’m looking to create a new contact/record from the data.

I tried reading over the documentation, but it lacks useful examples and overall I didn’t find the information very helpful or clear. Could somebody walk me through the steps necessary to submit data via a front-end form and save it to HubSpot? Specifically, if I have a JavaScript JSON object of form data, how might I submit that data to HubSpot using AJAX? Or is there some better way to do it?

Many thanks,
Sebastian


#2

HI @sebastianrb,

You’re correct, the issue here is that Marketing Free portals do not have access to the API, so for that specific portal no marketing scopes would be supported. Additionally, the HubSpot APIs do not support CORS / AJAX requests as this would expose any authentication you’re using for the request. The following document has some more information on this:

For a portal with access to the marketing APIs, you could use the Submit form data endpoint to pass your form submission into HubSpot (see below). This would update/create contacts in HubSpot, and the document includes some examples in various languages (PHP, C#, Node JS, etc.)