Installation
Include the SDK script after your form iframe:The SDK automatically discovers OpnForm iframes on your page and initializes
them. No additional setup required.
Automatic campaign attribution
The SDK automatically captures supported campaign parameters from the parent page and stores them with the submission undermeta.attribution. Parameters
already present in the iframe src take precedence over values from the parent
page.
Supported campaign parameters are utm_source, utm_medium, utm_campaign,
utm_id, utm_term, utm_content, utm_source_platform,
utm_creative_format, utm_marketing_tactic, gclid, gbraid, wbraid,
dclid, fbclid, ttclid, and msclkid.
Only these parameters are transmitted to the form. Other URL parameters and the
complete parent URL are not captured. A raw cross-origin iframe without the SDK
can only capture parameters included directly in its own src.
Quick Start
Events
Listen to form events to trigger custom actions, send data to analytics, or integrate with your application.Available Events
Listening to Events
Removing Event Listeners
Form Methods
Access form instances usingopnform.get('form-slug') and call methods to control the form.
Field Operations
setField(fieldId, value)
setField(fieldId, value)
Set the value of a specific field.
setFields(data)
setFields(data)
Set multiple field values at once.
getField(fieldId)
getField(fieldId)
Get the current value of a field.
getData()
getData()
Get all current form data.
clearField(fieldId) / clearAll()
clearField(fieldId) / clearAll()
Clear field values.
Error Handling
Theme Control
Navigation (Multi-Page Forms)
Form Actions
Popup Control
For forms embedded as popups:Global SDK Methods
Form Management
Initialization Options
Programmatic Form Creation
Integration Examples
Google Analytics 4
Send to Custom API
Error Tracking
Dynamic Field Population
Custom Code Integration
The SDK is automatically available when using the Custom Code feature in OpnForm. You can add custom JavaScript directly in your form or workspace settings, and thewindow.opnform SDK will be ready to use.
Adding Custom Code
- Go to your form’s Settings → Custom Code (or Workspace Settings for workspace-wide code)
- Add your JavaScript code in a
<script>tag - The SDK (
window.opnform) is automatically available
Example: Google Analytics Tracking
Example: Facebook Pixel
Example: Conditional Logic with External Data
Example: Custom Validation Feedback
Example: Live Data Change Tracking
Accessing Form Data Directly
Backward Compatibility
Existing embeds using
initEmbed() continue to work without changes. The
SDK provides full backward compatibility.Troubleshooting
Form not found
Form not found
Ensure the iframe has loaded and the Use
id attribute matches the form slug:opnform.getAll() to see discovered forms.Events not firing
Events not firing
Make sure the SDK script is loaded after the iframe:
Commands not working
Commands not working
Commands require the form to be ready. Use the
ready event:Auto-resize not working
Auto-resize not working
The SDK includes iFrame Resizer. If resize isn’t working, ensure:
- No CSS
max-heightrestricting the iframe - The form is not in
focusedpresentation style (which has fixed height)