Form EmbeddingWordPress

Email Input Field Trigger

Triggering via email input field submission

Use this when you have an email capture field on your page (for example in a hero section) and want submitting it to open your Surface Form with the email already filled in.

1. Add a form with the surface-form-handler class

Surface looks for a form with the surface-form-handler class and takes over its submission.

WordPress has no built-in form block, so add a Custom HTML block with a simple form:

<form class="surface-form-handler">
  <input type="email" name="email" placeholder="Enter your work email" required />
  <button type="submit">Get started</button>
</form>

If you build the form with a form plugin instead, add the surface-form-handler class to the form element — most form plugins have a CSS class setting for this.

We automatically prefill the email field based on the email input field.

2. Prefill Other Fields (Optional)

If you want to prefill fields other than the email input, you can do so by adding attributes to your form's input fields.

Identity Info Fields

For identity-related fields (except email), add a data-field-name attribute to the input:

<input type="text" data-field-name="firstName" placeholder="First name" />
Supported Identity Field Values
Field NameDescription
firstNameFirst name
lastNameLast name
emailAddressEmail address
phoneNumberPhone number
companyNameCompany name
numberOfEmployeesNumber of employees
websiteUrlWebsite URL
titleJob title
streetAddressStreet address
aptSuiteEtcApartment/Suite/etc.
cityCity
stateState
countryCountry
zipCodeZip/Postal code
companyRevenueCompany revenue

Other Form Fields

For all other fields (non-identity fields), you'll need to use the question ID from your Surface form:

  1. Get the Question ID from the Surface Form Builder.
  2. Add a data-question-id attribute to the input:
<input type="text" data-question-id="<question_id>" />

This method works with the following Surface form components:

  • Short Input
  • Long Input
  • Dropdown
  • Multiple Choice Question

3. Surface Form Constructor

Add the following script to your site's footer. With WPCode, go to Code Snippets > Header & Footer and paste it into the Footer section.

Add the data-question-id attribute to your Surface form script.

You must replace the <question_id> within data-question-id attribute below with the question ID from the Surface Form Builder.

<!-- Start Surface Form Embed -->

<script data-question-id="<question_id>">
  (function () {
     const surface_src = "surface_form_url";
     const surface_embed_type = "slideover"; // works on all embedding types!
     const target_element_class = "surface-form-button";
     const c = new SurfaceEmbed(
       surface_src,
       surface_embed_type,
       target_element_class,
     );
   })();
</script>

<!-- End Surface Form Embed -->

On this page