Widget Integration
Learn how to integrate FormLab Widget into your website.
FormLab Widget allows you to embed your forms into any website. The widget is highly customizable and supports multiple display types and launch triggers.
Installation
To add FormLab Widget to your website, simply copy and paste the provided code snippet where you want the form to appear:
<!-- FormLab Widget --> <div id="formlab-[your-form-id]"></div> <script async src="https://widget.formlab.ai/formlab-widget.min.js" data-form-id="[your-form-id]" data-config='{ "type": "standard" }' ></script>
Widget Types
FormLab supports four different widget types:
- Standard - Embeds the form directly into your page
{ "type": "standard" }
- Modal - Shows the form in a modal overlay
{ "type": "modal", "launch": { "trigger": "button" }, "button": { "text": "Open Form", "backgroundColor": "#0284c7", "textColor": "#ffffff" } }
- Popup - Displays a floating button that opens the form
{ "type": "popup", "launch": { "trigger": "button" }, "button": { "icon": "message-circle", "position": "bottom-right", "backgroundColor": "#0284c7", "textColor": "#ffffff" } }
- Full Page - Takes over the entire page
{ "type": "full-page" }
Launch Triggers
For Modal and Popup types, you can configure how the form is triggered:
- Button (default) - Shows a button that opens the form when clicked
- Page Load - Opens the form immediately when the page loads
- Time Delay - Opens the form after a specified delay
{ "launch": { "trigger": "time", "delay": 5000 // milliseconds } }
- Scroll Position - Opens when user scrolls to a certain percentage
{ "launch": { "trigger": "scroll", "scrollPercentage": 50 } }
- Exit Intent - Opens when the user is about to leave the page
{ "launch": { "trigger": "exit", "exitSensitivity": 20 } }
Programmatic Control
For Modal and Popup types, you can control the widget programmatically:
// Open the form window.FormLab.widgets['your-form-id'].open(); // Close the form window.FormLab.widgets['your-form-id'].close(); // Toggle form visibility window.FormLab.widgets['your-form-id'].toggle();
Performance
The widget script is automatically optimized for performance:
- Loads asynchronously to prevent blocking
- Prefetches form data for faster display
- Lazy loads resources as needed
Browser Support
FormLab Widget supports all modern browsers:
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Troubleshooting
If you encounter any issues:
- Check that your form ID is correct
- Ensure the script is loaded properly
- Check browser console for any errors
- Verify your configuration syntax