# Email Input Field Trigger





## 1. Add the HTML Form [#1-add-the-html-form]

Ensure your HTML form includes the `surface-form-handler` class. This class is essential for identifying the form as one that triggers the Surface Form popup. Example:

```html
<form class="surface-form-handler">
  <input type="email" placeholder="Enter your email" required />
  <button type="submit">Submit</button>
</form>
```

<Note>
  Add the &#x2A;*`surface-form-handler`** class to any external form that you want to use to trigger the Surface Form popup.
</Note>

## 2. Surface Form Constructor [#2-surface-form-constructor]

Add the following code to the &#x2A;*`pages/_document.tsx`** file:

```tsx
import Document, { Html, Head, Main, NextScript } from "next/document";
import Script from "next/script";

export default class MyDocument extends Document {
  render() {
    return (
      <Html lang="en">
        <Head>
          <Script
            id="surface-tag"
            src="https://cdn.jsdelivr.net/gh/trysurface/scripts@latest/surface_tag.min.js"
            data-site-id="SITE_ID" // Replace this with your Site ID
            strategy="beforeInteractive"
          />
          <Script
            id="surface-form-script"
            data-question-id="<question_id>" // Replace this with the question ID from the Surface Form Builder
            strategy="afterInteractive"
            dangerouslySetInnerHTML={{
              __html: `
                (function () {
                  const surface_src = "REPLACE ME WITH FORM URL"
                  const surface_embed_type = "popup"
                  const target_element_class = "surface-form-button"
                  const c = new SurfaceEmbed(surface_src, surface_embed_type, target_element_class)
                })();
              `,
            }}
          />
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}
```

Add the `data-question-id&#x60; attribute to your Surface Tag script in the &#x2A;*`pages/_document.tsx`** file.

<Note>
  You must replace the &#x2A;*`<question_id>`*&#x2A; within &#x2A;*`data-question-id`*&#x2A; attribute and &#x2A;*`REPLACE ME WITH FORM URL`** with the question ID from the Surface Form Builder and the form URL respectively.
</Note>

<Frame>
    <img alt="Question ID Location" src="__img0" />
</Frame>
