> ## Documentation Index
> Fetch the complete documentation index at: https://octanist.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Server-side form capture

> Send form submissions from your backend while keeping leads linked to Octanist pixel sessions.

Use server-side form capture when browser-side form detection is unreliable, blocked by another script, or not suitable for the website's form stack.

This setup keeps attribution intact by installing the Octanist pixel on the website, reading the hidden session ID from the submitted form, and sending the lead from your server to the Octanist API.

<Warning>
  Keep your Octanist API key on the server. Do not call the Create Lead API directly from browser JavaScript.
</Warning>

## How it works

1. The Octanist pixel creates a browser session.
2. The pixel injects a hidden session field into the form.
3. The visitor submits the form to your backend.
4. Your backend reads the hidden session ID and the form fields.
5. Your backend sends the lead to `POST /api/leads` with `sessionId`.
6. Octanist links the lead to the existing pixel session, page views, click IDs, UTMs, and consent state.

## Install the pixel

Install the Octanist pixel site-wide. If your backend sends the lead, remove `data-forms="true"` from the script so the browser does not also submit the same lead.

```html theme={null}
<script
  src="https://c.octani.st/p"
  data-id="OCT-XXXXXXXX"
  data-consent-mode="auto"
></script>
```

## Read the session field

The pixel injects this hidden field into normal forms:

```html theme={null}
<input type="hidden" name="octa_sid" value="..." />
```

For Elementor forms, it also injects:

```html theme={null}
<input type="hidden" name="form_fields[octa_sid]" value="..." />
```

Read that value in your backend and send it to Octanist as `sessionId`.

## Send the lead

Send the submitted form data to the Create Lead API from your backend:

```json theme={null}
{
  "externalId": "QUOTE-2026-0042",
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "+1234567890",
  "sessionId": "value-from-octa_sid"
}
```

Use `externalId` when your backend has a stable customer-owned identifier, such as an order number, quotation number, application ID, opportunity ID, or CRM lead ID. It is optional, unique within your organization, and makes retries idempotent.

If `sessionId` is valid, Octanist links the new lead to the existing pixel session. If it is missing, Octanist can still create the lead, but the lead may lose the original session and attribution context.

See [Create Lead](/docs/api-reference/endpoint/create-lead) for authentication, supported fields, and full request examples.

## AJAX forms

If your form submits through same-origin AJAX, the pixel also adds this request header when possible:

```text theme={null}
X-Octanist-Session-Id: value-from-octa_sid
```

Your backend can use either the hidden field or the header. Prefer the hidden field when available because it is part of the submitted form payload.

## Duplicate prevention

Use one capture method per form:

* Server-side form capture through your backend
* Browser-side pixel form detection through `data-forms="true"`
* WordPress server-side capture through the Octanist plugin
* GTM DataLayer lead sending

Do not enable multiple capture methods for the same form unless support has confirmed the setup.

If other forms on the same site still need browser-side detection, keep `data-forms="true"` on the pixel and add `data-octa-ignore` only to the forms your backend already sends:

```html theme={null}
<form data-octa-ignore>
  <!-- backend-captured form -->
</form>
```

If the form only exists in browser-side JavaScript and does not submit to your backend, use the [Client-side API](/docs/incoming-integrations/client-side-api) instead.
