> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nextlevelmca.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Embedded application form

> Choose the form's design, prefill it with answers from your page, count completed applications in Google Analytics, and keep the ad tags of the page the merchant landed on.

The application form can sit on your website through its embed code, one `<script>` line from **Settings → Application Form → Look & share** (**Share**, **Your website**). This page is for the developer of that website. It covers filling the form in with answers the merchant already gave on your page, what happens when a merchant submits so you can count each application once, and how the form keeps the ad tags of the page the merchant landed on.

## Choose the design

The form comes in three designs: `one-page` (the default), `steps` and `quick-start`. The account picks one in **Settings → Application Form**. An embed code can use another with `data-design`:

```html theme={null}
<script data-cfasync="false" data-no-optimize="1" data-no-defer="1" nowprocket src="https://securefundingportal.com/embed.js" data-token="YOUR_TOKEN" data-design="quick-start"></script>
```

A link to the form takes `?design=quick-start`. For an embedded form only the attribute counts: a `design` in your page's own address isn't passed on. Prefill, the submit message and ad tags work the same in every design.

In `steps` and `quick-start` the form changes screens inside its frame. It posts `{ type: 'mca-form-step', token }` to your page on each change, and the embed code scrolls your page back to the top of the form when the visitor has scrolled past it.

## Prefill the form from your page

When the merchant has already answered questions on your page, for example a short qualifier before the full application, hand those answers to the form so they don't type them again:

```html theme={null}
<script data-cfasync="false" data-no-optimize="1" data-no-defer="1" nowprocket src="https://securefundingportal.com/embed.js" data-token="YOUR_TOKEN"></script>
<script>
  MCAForm.prefill({
    owner_first_name: 'Ana',
    owner_last_name: 'Lopez',
    owner_email: 'ana@acmetrucking.com',
    owner_phone: '732-555-0199',
    business_name: 'Acme Trucking LLC',
    business_state: 'NJ',
    requested_amount: 50000,
    'Time in Business': '2+ years'   // a custom field, by the label the form shows
  }).then(function (result) {
    console.log(result.applied, result.ignored);
  });
</script>
```

The answers go from your page to the form inside the browser. They are never put in a web address and no API call is involved. `MCAForm.prefill` can be called straight after the embed code, or any time later: it waits until the form has loaded.

What the form does with them:

* **Fills empty fields only.** Nothing the merchant typed, or answers from an unfinished application they reopened, is replaced. The merchant can change anything you filled in.
* **Never takes an SSN, a signature, consent or the terms box.** The merchant gives those themselves.
* **Only takes fields the form shows**, formatted as if typed: `732-555-0199` becomes `(732) 555-0199`, `NJ` becomes New Jersey, `2019-04` becomes 04/2019. A choice must match one of the field's options (any capitalization).
* **Answers with what it used:** `result.applied` lists the keys it filled, and `result.ignored` lists the others, each with a reason such as `already filled in` or `not one of the field's options`.

Once the form has a first name and an email or phone, it saves the application as the merchant goes, as it does when they type. A merchant who leaves gets the usual unfinished-application follow-up with a resume link, see [Unfinished applications](https://docs.nextlevelmca.com/help/abandoned-applications.md).

### Field keys

`MCAForm.fields()` resolves with every field the form accepts, with its `key`, `label`, `type` and, for choices, its `options`:

```js theme={null}
MCAForm.fields().then(function (fields) { console.table(fields); });
```

The standard keys are `business_name`, `dba`, `ein`, `entity_type`, `business_address`, `business_city`, `business_state`, `business_zip`, `business_phone`, `industry`, `business_start_date`, `owner_first_name`, `owner_last_name`, `owner_email`, `owner_phone`, `owner_dob`, `ownership_percent`, `owner_credit_score`, `owner_address`, `owner_city`, `owner_state`, `owner_zip`, `annual_revenue`, `requested_amount` and `use_of_funds`, plus `owner2_first_name`, `owner2_last_name`, `owner2_email`, `owner2_phone`, `owner2_ownership_percent` and `owner2_credit_score` when the form offers a second owner. Only the ones your form shows are accepted. Custom fields from **Settings → Fields** can be passed by their key from `MCAForm.fields()` or by their label.

Dates can be sent as `YYYY-MM-DD` (or `YYYY-MM` for the business start date), amounts as numbers or text such as `$50,000`, and yes/no fields as `true`/`false` or `Yes`/`No`. A multiple choice field takes an array or a comma-separated list.

A form pasted in as a plain `<iframe>` takes the same message, once it has posted `{ type: 'mca-form-ready' }` to your page: `iframe.contentWindow.postMessage({ type: 'mca-form-prefill', token: 'YOUR_TOKEN', id: 'any-id', data: { … } }, 'https://securefundingportal.com')`. It answers with `{ type: 'mca-form-prefilled', id, applied, ignored }`.

## The application id

Every submitted application becomes a deal, and its id is the **application id** you get on your page. The same id comes back when the merchant sends the same application again (a lost connection, a second click), so counting each id once gives exact numbers. The id opens nothing without a sign-in to the workspace.

## What happens on submit

When an application goes through, the form shows its confirmation and posts a message to your page. The embed code then, in this order:

1. Pushes an event to Google Tag Manager's `dataLayer`:

   ```js theme={null}
   { event: 'mca_application_submitted', application_id: '2f1c…' }
   ```

2. Fires a `mca:application-submitted` event on `window`, with `detail.applicationId` and `detail.redirectUrl`. It can be cancelled.

3. Two seconds later, when **Redirect URL** is set, sends the whole page to it, with `application_id` added to the address:

   ```
   https://yoursite.com/thank-you?application_id=2f1c…
   ```

   Your own query string and fragment are kept.

### Count with Google Tag Manager

Create a **Custom Event** trigger for `mca_application_submitted` and a **Data Layer Variable** for `application_id`. Send it with your Google Analytics event tag, for example as `transaction_id` on a conversion.

### Count with gtag.js only

Without Tag Manager, listen for the window event:

```html theme={null}
<script>
  window.addEventListener('mca:application-submitted', function (e) {
    gtag('event', 'application_submitted', { application_id: e.detail.applicationId });
  });
</script>
```

Put it before the embed code. Count either the event or the thank-you page, not both.

### Handle the redirect yourself

Call `preventDefault()` in your listener and the embed code stays put. Then you decide where the page goes:

```js theme={null}
window.addEventListener('mca:application-submitted', function (e) {
  e.preventDefault();
  // e.detail.redirectUrl already carries application_id
});
```

## A form in a plain iframe

The embed code is what moves the whole page: browsers don't let a frame from another site move the page around it without a fresh click. A form pasted in as a plain `<iframe>` still posts the message, so you can listen for it yourself:

```js theme={null}
window.addEventListener('message', function (e) {
  if (e.origin !== 'https://securefundingportal.com') return;
  if (e.data && e.data.type === 'mca-form-submitted') {
    // e.data.applicationId, e.data.redirectUrl, e.data.token (your form's embed token)
  }
});
```

With a plain iframe and a **Redirect URL**, only the iframe moves to it.

## Ad tags

The embed code passes these tags from your page's address to the form:

| Tags | From |
| - | - |
| `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`, `utm_id` | Your campaign links |
| `gclid`, `gbraid`, `wbraid` | Google Ads |
| `fbclid` | Facebook and Instagram |
| `msclkid` | Microsoft Ads |

It also passes the page's address without its query string, and only the site of the page that sent the visitor (`https://www.google.com`, not the full address). Nothing else from your page's address reaches the form.

The tags are kept from the merchant's first visit: one who starts the application, leaves, and finishes later from a follow-up link keeps the tags of the visit that started it. On the deal they show in its activity, `utm_source` becomes its `lead_source`, and the API returns them all as `attribution` on [the deal](https://docs.nextlevelmca.com/developers/api/deals/get-a-deal.md).

## Rep links

A rep code works the same way as ad tags: `yoursite.com/apply?rep=CODE` assigns the application to that rep. See [Application on your own domain](https://docs.nextlevelmca.com/help/application-on-your-domain.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.