You are here:
Connect External Forms to Salesforce Objects with Form Handler
Use a form handler to capture data from a form on an external website and use that data to create or update records in Salesforce. Form handlers make it possible to use the existing forms on your site without updating your site to use forms created in Salesforce. When you create a form handler, you specify the field names in your existing form and the Salesforce fields that they map to.
Required Editions
| Available in: Enterprise and Unlimited Editions with Marketing Cloud Growth or Advanced Edition, and Pro Suite Editions. They also apply to these editions when Salesforce Foundations is enabled. Your edition determines the options that you have. |
| User Permissions Needed | |
|---|---|
| To create a form handler: | Marketing Cloud Manager permission set AND Any CMS workspace contributor role |
| To publish a form handler: | Marketing Cloud Manager permission set AND A CMS workspace contributor role of content admin or content manager |
When you create a form handler, you also create a data source in Data 360. This data source stores the data that you capture in your form. Before you create a form handler and a corresponding data source, think about how best to structure the data that you capture from the form. There are two general patterns for designing the data structure: explicit field names and generic field names.
In a data source that uses explicit field names, you specify each field name in the data model. This structure is easy to understand, but it requires you to modify the object every time you add a new field. A data model with an explicit structure resembles this example.
| Field Name | Type |
|---|---|
| First Name | Text |
| Last Name | Text |
| Text | |
| Address | Text |
| Occupation | Text |
| ... | ... |
Alternatively, a data source can use generic field names, or more often a combination of explicit and generic field names. This approach gives you more flexibility, because you can handle new field names without modifying the object. However, generic field names are ambiguous and require you to use metadata to describe the attributes in the payload. A data model with a generic structure resembles this example.
| Field Name | Type |
|---|---|
| First Name | Text |
| Last Name | Text |
| Text | |
| Attribute1 | Text |
| Attribute2 | Text |
| Attribute3 | Text |
| ... | ... |
Create a Form Handler
- On the Content tab, select a content workspace to create the form handler in.
- Click Add | Content.
- On the Create CMS Content window, select Form Handler, and then click Create.
-
In the top-left corner of the window, next to Untitled, click the pencil icon (
). Enter a name for the form handler.
-
Add a Data Source.
- In the panel on the right, under Data Source, click Add Data Source.
- Enter a name for the data source.
- For Type, select Salesforce Record.
- For Object, select the type of record the form handler operates on. For example, if you plan to use the form handler to update Contact records, select Contact.
- Save your changes.
-
Map the form fields.
- From the panel on the left, click a field that you want to capture from the form and drag it to the center of the page. For example, select the Contact object if your form collects information about the user’s First Name, Last Name, or Email address. Repeat this step for every field that the form data interacts with.
- In the center of the page, click one of the field names that you added. Then, in the panel on the right, enter an External Field Name. Repeat this step for all of the selected fields.
NoteKeep these requirements in mind when you specify the fields to capture:
- The external field name that you enter must exactly match the HTML name attribute of the field in your form.
- Date values must use the format
YYYY-MM-DD. - Time values must use the format
hh:mm:ss. - DateTime values must use the format
YYYY-MM-DDTHH:mm:ss.sssZ(ISO 8601 format). - For checkbox values, if the checkbox is selected on the form, it’s recorded as
truein the Salesforce object.
- Save your changes.
For information about updating your site to handle form submissions securely, see Developer Documentation: Integrate Form Submissions with the Connect API.
Add Spam Protection to a Form Handler (Optional)
Protect against hacking and spam by adding a hidden honeypot field to your form. When a bot tries to submit a form, it often completes every field in the form, even if the field is hidden. If you include a honeypot field in your form, the form handler blocks all submissions that include a value in that field.
- From the Spam Protection Fields panel, add the Honeypot field.
-
For External Field Name, enter a field name to use for the honeypot.
Tip Bots try to exploit form fields that let users freely enter text. They search for fields with generic labels, such ascompany,website, orfax. Enter a name that makes the honeypot field an appealing target, but also one that doesn’t overlap with the data you want to capture in the form. Don’t use an obvious name such ashoneypotordo_not_fill. - In your form’s HTML, add a hidden input field with the matching name attribute.
Automate Actions with a Flow
Connect a Salesforce Flow to automate tasks like creating leads or sending emails after a form is submitted. In the Flow section of the form handler, click New Flow to open Flow Builder.
When you create a flow from the form handler page, the external field names that you specified are available as resources in the flow. You can use the values of these external fields in flow decision steps, to personalize message content, and in other flow actions. You can also use these resources to modify any object, not just the object you selected when you created the form handler.
Configure Submission Redirects
In the Submission Redirect section, enter the full URLs to send users to when a form submission succeeds or fails.
Configure CORS Allowlist
Authorize your website’s domain by adding it to the CORS Allowlist. This step is required to permit form submissions.
Publish the Form Handler
Publish the form handler to generate the code to add to your website.
- When you’re ready to publish the form and its flow, click Publish.
- Under Tracking Script, click Copy.
-
In your webpage’s HTML, insert the copied script before the closing
</body>tag. - Under Form Attributes, click Copy.
-
Add the attributes to your website’s
<form>tag. - Turn on web tracking to monitor user engagement.

