Send Your Own Website Forms to LeadCentre
Give website enquiries a clear route into your sales process. Connect a supported custom form to LeadCentre through a server-side webhook, then manage the response and follow-up alongside your other leads.
Via Webhook: The platform posts each lead to your LeadCentre webhook URL.
What this does
Your form sends the enquiry to your own server. Your server shows the visitor your thank-you page and posts the details to your LeadCentre webhook URL, and LeadCentre creates a lead and sends the alert.
What you or your developer will need
- Somewhere to run code on the server. PHP on your hosting, a Node backend or a single serverless function will all do.
- An environment variable, or something like it, to hold the URL away from your code.
- A LeadCentre login with the Admin role, to create the key and match the fields.
Why the post comes from your server
A plain form with the webhook URL in its action attribute does reach LeadCentre, but you wouldn't want to keep it:
- Your visitor sees raw JSON. After pressing send, they land on a page reading something like ok: true, with no thank-you message and no way back to your site.
- Your key is in the page source. The URL contains the key, so anyone can read it and send junk into your account. All you could do then is replace it.
- Calling it from JavaScript in the browser has the same problem. The key is still visible there. The webhook is also built for server-to-server posts, so browsers block JSON posts to it and hide the response from other kinds.
Example: PHP
<?php
// contact.php receives your form, then passes it on.
$lead = [
'name' => $_POST['name'] ?? '',
'email' => $_POST['email'] ?? '',
'phone' => $_POST['phone'] ?? '',
'message' => $_POST['message'] ?? '',
];
$ch = curl_init(getenv('LEADCENTRE_WEBHOOK_URL'));
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($lead),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
]);
curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) !== 200) {
error_log('LeadCentre did not accept a lead');
}
header('Location: /thank-you');
Note json_encode on the fields. Passing PHP cURL an array sends multipart/form-data, and LeadCentre reads JSON and URL-encoded posts, so encode the fields first.
Example: JavaScript on your server
// Runs on your server, never in the browser.
const response = await fetch(process.env.LEADCENTRE_WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, email, phone, message }),
});
if (!response.ok) console.error('LeadCentre refused', response.status);
Send JSON.stringify or a URLSearchParams body, for the same reason. A FormData object sends multipart.
File uploads
Forms with a file input are sent as multipart/form-data, which LeadCentre refuses with a 415, so no lead is created. If your form takes files, have your backend receive the form, store the file, then post the text fields to LeadCentre as JSON, with a link to the file if you want one. Keep each post under 64 KB.
Spam
Check submissions on your backend before you pass them on. A hidden honeypot field or a captcha will stop most junk becoming leads and alerts.
Tracking which campaign a lead came from
Send any of these names with the enquiry and LeadCentre keeps them on the lead without being matched: utm_source, utm_medium, utm_campaign, utm_id, utm_term, utm_content, gclid, gbraid, wbraid, msclkid, fbclid, fbc, fbp, campaign_name, campaign_id, ad_group_name, ad_group_id, ad_name, ad_id, form_id, landing_page_url and referrer_url. Add them as hidden fields on your form, and have your backend pass them on.
We provide a small script that fills those hidden fields, so a visitor who arrives from an ad and moves to another page before enquiring still counts as coming from that ad. It sends nothing itself, and your site only uses it if you add it:
<script src="https://dashboard.leadcentre.com/lc-attribution.js" defer></script>
<form action="/contact.php" method="post" data-lc-attribution>
<!-- your own fields. The script adds the hidden ones to a form with this attribute. -->
</form>
If you need cookie consent, and in the UK you usually will for this, tell the script when the visitor agrees. Call this from your cookie tool:
LeadCentreAttribution.setConsent(true);
Until then it stores nothing and reads no click IDs, and the form only gets the campaign tags, landing page and referrer of the page it's on. With consent, it remembers the campaign for 90 days and reads Meta's _fbc and _fbp cookies if they already exist. It never creates them. Check this against your own privacy policy and cookie tool. Whether you need consent is your decision to make for your site.
How leads reach LeadCentre
Step 1
A visitor presses send
The form posts to your own server, and they see your thank-you page.
Step 2
Your server checks it
Validate the fields and turn away spam, using your own checks.
Step 3
Your server posts to LeadCentre
JSON or URL-encoded, using a URL kept in an environment variable, away from the page.
Step 4
LeadCentre answers and creates the lead
Your saved matching fills in the fields. Your server gets the result back, and the app gets a push notification.
How to set it up
- 1
Create a key and store the URL
In LeadCentre, go to Settings > Connections. On the Webhook tab, press "Add Another Key", type a name such as Website form and press "Create". Press "Copy". The URL is only shown once, so put it straight into your server's environment variables, not your code.
- 2
Add the post to your backend
Use one of the examples above, sending the field names you want to see in LeadCentre. Smart Match recognises short ones like name, email, phone, postcode, service and message.
- 3
Listen for your test
Follow "Next: test and match fields", or open the key from Settings > Connections, and press "Listen for test data". It lasts 15 minutes, and the page updates itself.
- 4
Send a test enquiry
Submit your form with every field filled in, because empty fields don't appear on the matching screen. They should appear under "2. Match the fields" a few seconds later. Developers can check the response at the same time: {"ok":true,"results":["test"]} means LeadCentre treated it as test data.
- 5
Match and save
Check Smart Match's suggestions, choose a field for each row you want to keep, or leave it on Do not use. If your backend creates its own enquiry reference, match it to Unique ID to stop duplicates. Press "Save field matching".
- 6
Stop listening and check
Press "Stop listening", or LeadCentre will treat your next real enquiry as test data. Submit one more enquiry and check it reaches your Leads list and you get the alert.
Supported fields
You decide the names because your backend sends them. These are the ones we'd use. The full list of LeadCentre fields and the technical limits are in the webhook reference.
| Field sent | Usually matched to |
|---|---|
| name, or first_name and last_name | Full name, or First name and Last name |
| phone | Phone (mobile or landline) |
| postcode | Postcode |
| service | Enquiry type |
| message | Enquiry / Message |
| landing_page_url, referrer_url, utm_source and the other tracking names above | Kept automatically |
| id (your own reference) | Unique ID (stops duplicates) |
Common problems
Nothing appears on the matching screen
Log the status code your server gets back, as it tells you where to look. A 401 means the URL or key is wrong, a 400 means LeadCentre couldn't read the body, and a 415 means you sent multipart. A 200 means it arrived, so check you're on the right key's page and that listening hasn't run out. An empty value doesn't appear as a field.
LeadCentre answers with a 415
You're sending multipart/form-data, and no lead was created. In PHP, wrap your array in json_encode or http_build_query. In JavaScript, send JSON.stringify or a URLSearchParams body in place of FormData.
Posts come back as awaiting_mapping
Your code is live on a key with nothing matched yet. Recent activity shows those as "Waiting for field matching", and they're held. Press "Save field matching" and they become leads, with a banner saying how many were added.
Posts show "No name, phone or email" under Recent activity
None of your matched fields held a name, phone or email. This often follows a rename in your form or backend. Match the new name and save, and LeadCentre retries those posts.
My key has been exposed in page source or a repository
Open the key and press "Replace this URL". The old one stops at once, and your field matching stays. Move the new URL into an environment variable and post from your backend. Archive any junk it let in.
The URL isn't in my environment variables any more
Check your hosting's settings and any other environments first, because LeadCentre keeps only a scrambled copy. If it's gone, press "Replace this URL", or "Get a URL to copy" if it has never been used, and update your server.
I need to rotate the key as part of a deployment
The old URL stops the moment you press "Replace this URL", and anything sent to it gets a 401. Have your deployment ready, which keeps the gap short, and log enquiries on your side in case any need sending again.
Questions about this connection
My site has no backend at all. What can I do?
Add one small serverless function, which most static hosts support. Or move the form to a tool that sends webhooks for you, or to a form tool with a Zapier or Make trigger.
Do I have to send JSON?
No. LeadCentre also reads a URL-encoded form post. It decides from the body itself, so a wrong Content-Type header isn't a problem. The only format to avoid is multipart/form-data.
What if a post doesn't go through?
Don't make your visitor wait or show them an error. Set a short timeout, show your thank-you page regardless and keep your own record, such as a notification email. You can then deal with any missed enquiry by hand.
Can I send the key in a header?
Yes. Remove the ?key= part from the URL and send the key in an x-api-key header. This keeps it out of server logs that record URLs.
Set up your Connections
Set up your LeadCentre account and add this Connection, and your next enquiry can arrive on your phone.
