HubSpot
What it does
Creates records in HubSpot from each new submission of a form: a contact, a company, a ticket, or any mix of the three. The ticket is linked to the contact and the company it came with.
What HubSpot receives:
- Contact: the email address, the first and last name, the Contact Lifecycle Stage and Contact Lead
Status you chose, the owner, and the fields you map. The name comes from the customer account when a signed-in
customer sends the form. For a guest, the submitter name of the form goes in the last name, or
Guestwhen the form has none. See Submission Identity in Form settings. - Company: the email address as the company owner's email, and the fields you map.
- Ticket: the submission title as the subject, with the reference number in front when the form has one (a field with Hide in Submissions only when its Allow in Staff Email Subject is on), the pipeline, status, priority, source and owner you chose, and the fields you map.
- Files: a File field you map is uploaded to HubSpot's file manager, in a folder named
webforms, and attached to the record through a note. HubSpot keeps these files so that anyone with a file's link can open it; search engines don't list them. Map only files you're happy to store that way.
Only the email address, the name, the submission title and the mapped fields leave your store. If the submission title is made from answers, those answers go too. Other answers you don't map aren't sent.
A field with Hide in Submissions stays in the ticket's subject when its Allow in Staff Email Subject is on, as in the subject of emails to your team. When Contact is switched on too, the ticket is linked to the visitor's contact, and anything HubSpot sends or shows that contact about the ticket carries its subject. Switch that setting on only for a value the visitor may see.
Install
composer require mageme/module-webforms-addon-hubspot
bin/magento setup:upgrade
Settings
Connect your HubSpot account
Go to Stores → Configuration → MageMe Extensions → WebForms, expand Integrations, then HubSpot. Paste the access token of a private app you created in HubSpot into Access Token and click Save Config. The connection is the same for every store view.
Give the private app access to what WebForms uses in HubSpot: read and write for contacts, and for companies and tickets if your forms send them; read for owners, properties and pipelines, which fill the lists in the form's settings; and files and notes if your forms send uploaded files. See Settings: Integrations for Show All Properties and the duplicate protection settings.
Choose what a form sends
- Go to Content → WebForms → Manage Forms and click the form's name.
- Under Form Information, click HubSpot Integration Settings.
- Select Yes in Enable HubSpot Integration.
- Switch on Contact, Company or Ticket, or several of them.
- For a contact, select Yes in Update Existing Contacts if a contact that already has this email address should get the new details. With No, the existing contact is left as it is.
- For a company, Update Existing Companies does the same for a company with the same domain.
- Pick the lifecycle stage, lead status, ticket pipeline, ticket status, priority, source and Owner you want.
- In Customer Email, keep Default or pick the form's email field. Default is the address in the form's Submitter Email setting, or the customer account's address.
- Under Fields Mapping, click Add for each HubSpot property you want to fill. Pick the property in HubSpot Attribute and the form field in Field.
- Click Save.
The lists in these settings come from your HubSpot account. On a saved form with the account connected, click Refresh Lists in the section to load them, or to load them again after you change something in HubSpot. Until then the section says "Lists load after Refresh Lists."
While no account is connected, the section is still there, but its lists are empty, it has no Refresh Lists button and nothing tells you why. Connect the account first.
How it works
When a visitor submits the form, WebForms saves the submission and then queues it for HubSpot. The queue is worked through by Magento's scheduled tasks (cron), so the records appear in HubSpot shortly after the visit. A form set to Do Not Store Submissions sends during the visit instead. Editing a submission later doesn't send it again.
The contact is created first, then the company, then the ticket. A contact needs an email address: a submission without one sends only the company and the ticket, and if only Contact is switched on, it's skipped.
To send submissions that already exist, or to send one again:
- Go to Content → WebForms → Manage Forms.
- In the form's row, click Select in the Actions column, then click Browse Results.
- Select the checkboxes of the submissions.
- Click Actions, then Send to HubSpot, and confirm.
WebForms reports how many submissions were sent, skipped and failed. Send to HubSpot is in the menu only while the integration is on for the form and an access token is saved, and only for admins with the Edit Result permission.
A repeated send finds the existing contact by its email address. It creates a second ticket unless Deduplicate Tickets by External Key is Yes in the store configuration.
To check that it worked, look for the contact or ticket in HubSpot. WebForms doesn't mark a submission as sent.
Troubleshooting
- Nothing reaches HubSpot. Check that Enable HubSpot Integration and at least one of Contact,
Company and Ticket are on for the store view the form was sent from, and that Access Token is saved.
Ask whoever runs your server to check that Magento cron is running and to search Magento's system log for
"HubSpot" in any letter case. The lines about sending start with "WebForms integration" and name the service in
lowercase, as
hubspot. A skipped submission is logged with the reason, such as "HubSpot is not configured" or "no e-mail value". - The contact was created but the company or ticket is missing. Once the contact exists, a failed company or ticket isn't tried again; the error is in the log. Fix the cause, then send the submission again from the list.
- HubSpot didn't answer, or answered with a server error or "too many requests". WebForms tries again, up to three tries in all, waiting longer before each one. After the third failure it gives up and writes an error to the log.
- The access token was refused. The log shows a line from HubSpot with "HTTP 401", followed by "WebForms
integration: delivery failed" for
hubspot: WebForms tries three times and then gives up. Sending from the list reports "HubSpot did not accept the credentials". Create a new token in HubSpot, paste it into Access Token, save, and send the waiting submissions again from the list. - A list in the form's settings is empty. Click Refresh Lists. If a message says the lists couldn't be refreshed, check the access token. Turn on Show All Properties to see properties that aren't marked for use in forms in HubSpot.
What's next
- Settings: Integrations: the HubSpot connection and duplicate protection.
- Integrations: the other services WebForms can send to.
- File field: what visitors can upload.