---
schema_version: "1"
id: 933e5335e63250b9d288bcc46a872ee0b53b519b042ca940a21d4d62c41e39cd
title: Connect an External Form to a Form Handler
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mktg_content_form_handler_connect.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mktg_content_form_handler_connect.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 6d04a087f8b2e1727781dc294c9dc5191b129463bcbe066dbedf628c7ed9339c
description: After you create and publish a form handler, configure your external form to send data to Salesforce.
products:
  - Marketing
release: "264"
---
# Connect an External Form to a Form Handler

After you create and publish a form handler, configure your external form to send data to Salesforce.

### Required Editions

[View supported editions](https://help.salesforce.com/s/articleView?id=mktg.mktg_editions.htm&release=264.0.0&type=5 "Marketing Cloud Next is available in Growth and Advanced editions, and requires Salesforce Enterprise or Unlimited editions. Some features are limited by edition or purchased add-on. All functionality is available in Lightning Experience only.").

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col>
          <col>
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d28539e47">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">To create a form handler:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">
              <p>Marketing Cloud Manager permission set</p>
              <p>AND</p>
              <p style="margin-bottom:0;">Any CMS workspace contributor
                role</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">To publish a form handler:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">
              <p>Marketing Cloud Manager permission set</p>
              <p>AND</p>
              <p style="margin-bottom:0;">A CMS workspace contributor role of
                content admin or content manager</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">To configure the CORS allowlist:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e47 ">Modify All Data</td>

          </tr>
        </tbody>
      </table>

Before you complete these steps, [create and publish a form handler](https://help.salesforce.com/s/articleView?id=mktg.mktg_content_form_handler.htm&release=264.0.0&type=5 "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.").

There are two ways to send data from your form to Salesforce. Select the connection type that best suits the structure and capabilities of your site.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d28539e122">&nbsp;</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d28539e124"><strong>JavaScript Snippet (Client-Side)</strong></th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d28539e128">
              <p style="margin-bottom:0;"><strong>Direct POST URL (Server-Side)</strong></p>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>How it works</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">A script on your page sends form data to Salesforce when a visitor submits the
              form.</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">Your form posts data directly to a Salesforce URL, with no script on the page.</td>

          </tr>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>Add to your site</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">A <code>&lt;script&gt;</code> tag and form attributes that you paste into the HTML
              for your page.</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">A URL that you set as the action for your form or webhook destination.</td>

          </tr>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>Best suited for</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">Pages where you control the HTML and can add scripts.</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">Third-party form builders that don’t allow custom scripts, pages with strict Content
              Security Policy (CSP) rules, and forms that post from a backend server.</td>

          </tr>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>Supports web tracking</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">Yes</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">No</td>

          </tr>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>Supports identity resolution</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">Yes</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">No</td>

          </tr>
          <tr class="">
            <td data-label="" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e122 "><strong>Requires a CORS Allowlist entry</strong></td>

            <td data-label="JavaScript Snippet (Client-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e124 ">Yes</td>

            <td data-label="Direct POST URL (Server-Side)" class="slds-cell-wrap" style="vertical-align:top;" headers="d28539e128 ">Yes</td>

          </tr>
        </tbody>
      </table>

Both methods send data to the same form handler and trigger the same flow. Both methods also require you to authorize your domain in the [CORS Allowlist](https://help.salesforce.com/s/articleView?id=mktg.mktg_content_form_handler_connect.htm&release=264.0.0&type=5 "Both connection methods require you to authorize your domain before Salesforce accepts form submissions. If you don’t authorize your domain, then Salesforce blocks the submission before it’s processed. To authorize your domain, add it to the CORS Allowlist.").

With either type of connection, make sure each field in your form uses an HTML `name` attribute that exactly matches the corresponding external field name in the form handler. If the names don’t match, the form handler doesn’t capture the value. For example, if you mapped the external field name `email_address` to the `Email` field, the `name` attribute for the corresponding field in the form must also be `email_address`.

## Option 1: Configure Your Form to Use a Client-Side Connection

Use this method when you control the HTML for your page and can add a script to it. Because the script runs in the visitor’s browser, this method supports web tracking and identity resolution. As a result, this method can connect a form submission to a visitor’s web activity.

1. Publish the form handler.
2. On the Code Snippet tab, under Client-Side Form Handler, copy the tracking script. The script resembles this example.
    
    ```
    <script async src="https://YOUR_DOMAIN/lp/assets/scripts/external-form-handler-host.min.js" onload="SFDCFormHandler.init('https://YOUR_DOMAIN/lp')"></script>
    ```
3. In the HTML code for the site, paste the script before the closing `</body>` tag.
4. On the Code Snippet tab, copy the form attributes. The attributes resemble this example.
    
    ```xml
    <form id="CONTENT_KEY" data-uma-forms="true"></form>
    ```
5. In your HTML, add the `id` and `data-uma-forms` attributes to the `<form>` tag.
6. Confirm that the HTML `name` attribute for each form field matches the mapped external field name.
7. [Add the domain that hosts your form to the CORS Allowlist](https://help.salesforce.com/s/articleView?id=mktg.mktg_content_form_handler_connect.htm&release=264.0.0&type=5 "Both connection methods require you to authorize your domain before Salesforce accepts form submissions. If you don’t authorize your domain, then Salesforce blocks the submission before it’s processed. To authorize your domain, add it to the CORS Allowlist."). This step authorizes your domain to send submissions to Salesforce.
8. To monitor user engagement, turn on web tracking.

When a visitor submits the form, the script sends the data to Salesforce, and the form handler processes the submission and triggers your flow. The form handler then redirects them to the success or error URL that you configured.

## Option 2: Configure Your Form to Use a Server-Side Connection

Use a server-side connection when you aren’t able to add code to your page or make custom configurations to your code. With this method, the form handler gives you a destination URL, and you configure the form to send its data to that URL. Because you don’t embed a script, this method works with form tools that don’t allow custom JavaScript. This method is also useful with pages that have strict Content Security Policy (CSP) rules, and with forms that submit from a backend server.

1. On the Code Snippet tab for the form handler, under Server-Side Form Handler, copy the form action URL. The URL resembles this example.
    
    ```
    https://YOUR_DOMAIN/lp/cms/form/submit/v1/CONTENT_KEY
    ```
2. Configure the form to send the data to Salesforce. The implementation steps depend on how you implement your form.
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small "><tbody><tr class=""><th style="vertical-align:top;" headers="d28539e386-option" id="d28539e390">If you use a third-party form builder or plugin</th><td style="vertical-align:top;" headers="d28539e386-desc d28539e390">In the settings for the third-party tool, find the field for configuring the form’s action, post-to URL, or webhook destination. Enter the Salesforce URL in that field.</td></tr><tr class=""><th style="vertical-align:top;" headers="d28539e386-option" id="d28539e399">If you can modify the HTML but can’t add a script</th><td style="vertical-align:top;" headers="d28539e386-desc d28539e399">Set the <code>action</code> attribute of your <code>&lt;form&gt;</code> tag to the Salesforce URL, and set the <code>method</code> attribute to <code>POST</code>.</td></tr><tr class=""><th style="vertical-align:top;" headers="d28539e386-option" id="d28539e420">If your form uses a backend process</th><td style="vertical-align:top;" headers="d28539e386-desc d28539e420">Send a POST request to the Salesforce URL with the form data, with <code>application/x-www-form-urlencoded</code> encoding.</td></tr></tbody></table>
3. Confirm that the name of each field matches the mapped external field name exactly.
    
    The form handler captures fields only when they match exactly.
4. [Add the domain that hosts your form to the CORS Allowlist](https://help.salesforce.com/s/articleView?id=mktg.mktg_content_form_handler_connect.htm&release=264.0.0&type=5 "Both connection methods require you to authorize your domain before Salesforce accepts form submissions. If you don’t authorize your domain, then Salesforce blocks the submission before it’s processed. To authorize your domain, add it to the CORS Allowlist."). This step authorizes your domain to send submissions to Salesforce.

## Configure the CORS Allowlist

Both connection methods require you to authorize your domain before Salesforce accepts form submissions. If you don’t authorize your domain, then Salesforce blocks the submission before it’s processed. To authorize your domain, add it to the CORS Allowlist.

1. Identify the domain that hosts the form, such as `https://www.example.com`. To authorize all subdomains, use a wildcard, such as `https://*.example.com`.
2. [Add the domain to the CORS allowlist](https://help.salesforce.com/s/articleView?id=xcloud.extend_code_cors.htm&language=en_US).

## Test the Form

After you connect your form to the form handler, test it to make sure that it behaves the way you expect it to.

1. On the form, submit a test entry and confirm that you’re sent to the success URL.
2. In Salesforce, check to see if a record corresponding to the test entry was created or updated.
    
    ![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-mktg-mktg_all-264-0-0-production-enus/e92be4e1-4bef-47a5-a11d-95f4ea1f7d7a/images/icon_tip.png)
    
    Tip If a record isn’t created or updated after submitting a test entry, confirm that each form field’s name attribute matches an external field name. If the form handler is connected to a flow, confirm that the flow completes without errors.