- Submit a custom-built form on your website to Conversion
- Listen for submissions from embedded Conversion forms
- Set field values on embedded Conversion forms
- Capture UTM parameters and other page context alongside submissions
Installation
Add the Forms SDK script to every page where you use a Conversion form:head or body), so long as it loads.
Each form exposes a code snippet that includes the Forms SDK script, but only one script is needed per page.
The Conversion pixel (website tracking script) is still required alongside the Forms SDK: it sets the tracking cookies that associate submissions with the visitor’s tracking ID. Without it, submissions are not linked to tracked visitors.
Finding your form and field IDs
The examples below reference two kinds of identifiers:- Form ID: shown in the form’s embed snippet and in the dashboard URL when the form is open.
- Field IDs: listed in the Form fields table under your form’s Advanced settings, for both displayed and hidden fields.
Submitting a custom form
If your form is custom built on your website,ConversionFormsV1.submit() sends its submissions to Conversion. It takes your Conversion form ID and an object mapping field IDs to values, and returns whether the submission was accepted:
If an email address is not passed through a form, it will not be mapped to or create a contact.
Step by step
1
Create a Conversion form
Create a form in the dashboard with an input for each value you want to send. The form must be Published to accept submissions.
2
Add the SDK script
Make sure the Forms SDK script appears on the webpage with your form.
3
Map your field IDs
Copy each field’s ID from the form’s Advanced settings into a helper object:
4
Listen for your form's submit event
Read your form’s values when the visitor submits it. Keys on
data match the name attribute of each input, e.g. <input name="email" /> is read as data.email:5
Call ConversionFormsV1.submit
Inside the listener, pass the values to Conversion keyed by field ID:
6
Check whether the submission succeeded
submit() resolves to true when the submission was accepted.Complete example
What is included automatically
When available, the SDK automatically attaches the visitor’s tracking ID, session ID, page URL, and referrer to everysubmit() call, so submissions are attributed to the right contact and session without extra work.
Capturing UTM parameters
UTM parameters are not captured automatically. To store them with a submission, add a hidden field to your form for each parameter, then read the values from the page URL and pass them like any other field:set-values message instead.
Working with embedded forms
Embedded Conversion forms render inside an iframe, and the Forms SDK script on the parent page keeps them connected: it resizes the iframe to fit the form and shares the visitor’s tracking context. You can also exchange messages with the iframe to react to submissions and update field values.Your form’s Advanced settings generate these snippets pre-filled with your form and field IDs.
Listening for submissions
When an embedded form is submitted, it posts aconversion-forms message with the submitted event to the parent page. This is useful for firing analytics events or triggering your own UI:
fields object maps each field ID to its submitted value.
Setting field values
Send aset-values message to pre-fill visible fields or populate hidden fields (for example, with UTM parameters). Wait for the form’s conversion-forms-ping message so you know the form is ready:
To clear a previously set field, set its value to
null.Conditional fields
If your Conversion form uses conditional fields, the same visibility rules are enforced for SDK submissions: fields hidden for the visitor are never required, and values submitted for them are discarded.Debugging failed submissions
Ifsubmit() fails and returns false, you can see details about why the form submission failed in the API response to forms.conversion.ai, located under the “Network” developer tab.