Put a Subcontext lead form on your own website, or send leads from a form you already have.
You can use it in two ways:
- We draw the form. You paste two lines of code. The form you designed in Subcontext appears on your page. It checks what people type, sends it, and thanks them.
- Your own form (also called "headless", meaning we draw nothing). You keep your own form, or have no form
at all, and send each lead with one line of JavaScript:
Subcontext.createLead(...). The script still checks the details, adds where the visitor came from, sends the consent answers, runs the bot check and retries if the connection drops.
Every lead arrives on the form's campaign in Subcontext, with the person's consent answers, where they came from (the page, the referring page, campaign tags and ad clicks) and any extra details you send.
For a priced quote instead of an enquiry, use the Subcontext quote form. To send leads from a server, use the leads API. See Sending leads from a server.
Quick start#
- In Subcontext, open CRM > Campaigns, pick your campaign, open the Capture tab and add a lead form.
- On the form's Install tab, add your website under Websites that may use it (for example
https://www.example.com) and press Save websites. - Copy the snippet under We draw the form and paste it into your page where the form should appear. It looks like this:
<div data-subcontext-leadform></div>
<script src="https://js.subcontext.com/leadform-latest.js" data-key="lfk_YOUR_KEY" defer></script>
- Open your page, fill in the form and send it. The lead appears on the campaign.
The other pages in this guide cover changing how the form looks or behaves, and using your own form.
Before you start: set up in Subcontext#
Do these in the Subcontext dashboard at https://subcontext.com.
- A campaign (CRM > Campaigns). It must be active. If it is paused or archived, the form stays on your page but says "This form isn't taking enquiries at the moment."
- A lead form on that campaign. Open the campaign, go to the Capture tab and add a lead form. A campaign
can have several lead forms, each with its own key, design and results. You can also find all your lead forms
under CRM > Lead forms. Each form has three tabs:
- Design: the pages and fields, the wording, the look, which consent boxes to show, who gets an email about each enquiry, and an optional chat to open after sending.
- Install: the websites allowed to use the form, its key (
lfk_...), the built-in bot check, and two snippets to copy: We draw the form and Your own form. - Results: how many people saw, started and sent the form.
- The form switched on. A form that is turned off refuses every request with
form_disabled. - Your website on the allowed list. On the Install tab, under Websites that may use it, add each
website, one per line. Only pages on these websites can send leads.
- Each entry must match exactly, including
https://orhttp://, the full host name, and any port.https://example.comandhttps://www.example.comare two different websites. If your site works on both, add both. - You can paste a full page address. It is reduced to the website part (for example
https://www.example.com/contactbecomeshttps://www.example.com). - If a website that isn't on the list tries to use the form, the firm's owners and managers get a notification (at most once a day per website).
- Each entry must match exactly, including
- Your consent wording. Under Consent, the "website lead form" rules hold the wording the form shows. The notice is always shown. Which marketing boxes appear is chosen on the form's Design tab. See Consent.
- An account that can take leads. If your Subcontext subscription has lapsed, the form stays on your page
but stops taking leads (error
not_entitled).
Sending leads from a server#
If leads come from your own back-end, a partner, or another system rather than a visitor's browser, use the Subcontext leads API instead of the lead form:
POST https://subcontext.com/api/v1/crm/ingestswithContent-Type: application/json.- Authorise with an API token (
Authorization: Bearer <token>) from API applications in the dashboard, with the write and crm scopes. This token is a secret. Keep it on your server and out of web pages. - Send an
Idempotency-Keyheader, unique to each submission, so a retry never makes a second lead. - Give the campaign's key (on the campaign's page) so the lead lands on the right campaign.
How to get the token, which kind of API application to use (one with no allowed websites), and a working
example that sends a lead (send-lead.mjs) are in the access tokens guide.
The API takes consent by purpose and channel, with your evidence of it (the wording shown, when, where, IP address and browser), including third-party consent by post. The full reference, with examples, is the help article Sending leads in: everything you can send (linked from the form's Install tab, Everything you can send, with examples).
Example pages#
The example pages are complete web pages that show the lead form in use, from the simplest install up. You can read, copy or download each one.
In this section
- Install the lead form Paste in the drawn form, change it for one page or set it up from JavaScript, or send leads from your own form.
- Options and styling Every setting for the script tag, the form element and init(), your own wording and error messages, and how to style the form.
- JavaScript API and events The lead form's JavaScript calls, form handle, results, events and callbacks, what a lead can carry, and the chat after the form.
- Provenance, values and consent Where the visitor came from, prefilled and hidden values, and how consent answers are asked for and recorded.
- Security and troubleshooting What is public and what is checked, content security policy, limits, and every error code with what to do.
- Example pages Six complete pages to copy, from the paste-in snippet to sending leads from your own code.