Skip to main content
The Forms SDK allows you to send submissions programmatically to Conversion, in case your forms are custom built on your website.

Forms SDK Script

Here is the Forms SDK JavaScript snippet, which needs to appear on each website page where you are using any Conversion form:
{/*  Add the Conversion Forms SDK script to your website  */}
<script src="https://forms.conversion.ai/script.js"></script>
You can place this script anywhere on the webpage (in the head or body), so long as it loads.
Each form will expose a code snippet that includes the Forms SDK script, but only one script is needed per page.

Using the Forms SDK

The following sample JavaScript snippet shows how to send submissions programmatically using the Forms SDK:
{/*  Add the Conversion Forms SDK script to your website  */}
<script src="https://forms.conversion.ai/script.js"></script>

// Optional utility to access fields by their names
const FORM_FIELDS = {
  email: "<FIELD_ID>",
  name: "<FIELD_ID>",
};

// Example form element
const form = document.getElementById("my-form");

form.addEventListener("submit", async (event) => {
  event.preventDefault();

  const formData = new FormData(form);
  const data = Object.fromEntries(formData.entries());

  const submitted = await window.ConversionFormsV1?.submit(
    "<YOUR_FORM_ID>", 
    // Must be an object of key-value pairs, where keys are
    // form field identifiers and values are field values
    {
      [FORM_FIELDS.email]: data.email,
    }
  );

  // true if the submission was successful, false otherwise 
  console.log(submitted);
});
</script>
Replace <YOUR_FORM_ID> with your form ID, and <FIELD_ID> with your form field IDs.
Steps to send submissions programmatically:
1

Create a new Conversion form

First, create a new Conversion form in the dashboard and configure the fields you want to send over.
2

Add the Forms SDK script

Make sure the Forms SDK script above appears on the webpage with your form.
3

Define a helper object

Define a helper object to store the field IDs for each field. These IDs are used to reference field data in your code.
4

Wait for a form submission

Add an event listener to your form that listens for the submit event.
5

Call ConversionFormsV1.submit

Pass the form fields by field ID into ConversionFormsV1.submit().
If an email address is not passed through a form, it will not be mapped to or create a contact.
6

Check if submission was successful

ConversionFormsV1.submit will return whether the submission was successful.
If any of the submitted fields failed field validation, the submission will not be successful.