Hubspot form integration with Drupal webforms
This guide covers using Drupal webforms functionality to remote-post form submission data to Hubspot via their form submission API.
Read the Hubspot API guidance on the from submission API. As this is a server-to-server request, you should use the unauthenticated endpoint.
Steps to set up the integration
Set up your form in HubSpot (see the Hubspot articleCreate and edit forms). Take note of the internal name of each field.
Create a new Drupal webform by navigating to /admin/structure/webform.
Add the same fields in Drupal as in Hubspot. Note the key field must be the same as the internal name in hubspot. If the label is different to the field name you can click the edit button to change it.
Next you need to set up the handler to submit the form to Hubspot. To do this, navigate to settings > Emails / Handlers and then Add handler.
Then add the Remote Post option.
In the Completed URL field, add the form submission URL that is unique to your Hubspot account and form. The form submission API URL is in the following format: https://forms.hubspot.com/uploads/form/v2/:portal_id/:form_guid,
where:portal_id
is your unique Hubspot portal ID (see https://community.hubspot.com/t5/Account-Settings/where-do-I-find-my-Hub-ID/m-p/647331/highlight/true#M29807)
and:form_guid
is the unique form id (see Find your form GUID)To configure the Drupal form to automatically purge submissions:
Go to Settings > Submissions > Submission purge settings.
Setting this to 1 day will automatically purge submissions from Drupal each day.
Note: the submission does need to be saved in Drupal so this method is not suitable for sensitive submission data which must not be stored in Drupal.