How to send data to Facebook with forms
Last updated: May 28, 2025
Overview
You can use a script to send data like a contact's email address and phone number to Facebook via Sendlane form.
Read on to learn how the script works and where to install it.
Install the script
The script below sends a contact's email address, phone number, first name (1), and last name (2) to Facebook when a button set to submit is clicked.
To send data from your form to Facebook, install the script on the line after your form installation script.
<script>
window.addEventListener('sendlaneForms', e => {
if (e.detail.type === 'submit') {
const metadata = e.detail.metaData;
fbq('track', 'Lead', {
email: metadata.email,
phone: metadata.phone,
firstName: metadata.$1,
lastName: metadata.$2,
});
}
});
</script>