Lead form

Put a Subcontext lead form on your website, or send leads to a campaign from a form you already have.

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#

  1. In Subcontext, open CRM > Campaigns, pick your campaign, open the Capture tab and add a lead form.
  2. 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.
  3. Copy the snippet under We draw the form and paste it into your page where the form should appear. It looks like this:
html
   <div data-subcontext-leadform></div>
   <script src="https://js.subcontext.com/leadform-latest.js" data-key="lfk_YOUR_KEY" defer></script>
  1. 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.

  1. 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."
  2. 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.
  3. The form switched on. A form that is turned off refuses every request with form_disabled.
  4. 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:// or http://, the full host name, and any port. https://example.com and https://www.example.com are 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/contact becomes https://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).
  5. 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.
  6. 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/ingests with Content-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-Key header, 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

Stuck, or something missing?

Get in touch and a person on the team will help.

Contact us