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

# JS SDK: Submit Referred Leads with Partner Attribution

> Call kiflo('lead', ...) when a prospect submits a form to attribute the lead to their referring partner and trigger partner rewards.

Call `kiflo('lead', ...)` each time a new lead is submitted on your website — for example, when someone fills out a "Request a Demo" or "Contact Us" form. Kiflo reads the referral tracking cookie from the visitor's browser, identifies which partner referred them, and records the lead with full attribution so your partner can be credited or rewarded.

## Syntax

```javascript theme={null}
kiflo('lead', {
  // leadObject
},
function(response) {
  // handle success
},
function(error) {
  // handle error
});
```

Both callback functions are optional. Omit them if you do not need to act on the result synchronously.

## Example

```javascript theme={null}
kiflo('lead', {
  properties: {
    firstName: 'John',
    lastName: 'Doe',
    email: 'john.doe@example.com',
    // your custom lead properties
  },
  status: 'Accepted' // optional
},
function(response) {
  // handle success  
},
function(error) {
  // handle error
});
```

## Parameters

### LeadObject

<ParamField body="properties" type="object" required>
  The properties of the lead as configured in your Kiflo [account properties](https://app.kiflo.com/account/properties). The `firstName` and `lastName` fields are required. You can include any additional custom properties you have defined for leads.

  ```json theme={null}
  {
    "firstName": "John",
    "lastName": "Doe",
    "email": "john.doe@example.com",
    "company": "Acme Corp"
  }
  ```
</ParamField>

<ParamField body="status" type="string">
  The initial status to assign to the lead in Kiflo. Common values are `"Accepted"`, `"Pending"`, and `"Rejected"`. If omitted, Kiflo applies the default status configured in your account.
</ParamField>

## How Kiflo tracks partner referrals

When a visitor follows a partner referral link to your website, the Kiflo JS snippet stores a unique tracking code in a first-party browser cookie (`kfl_key`). That cookie lives for up to 30 days. When a visitor later submits a form and you call `kiflo('lead', ...)`, the SDK reads the cookie and automatically includes the tracking code in the request to Kiflo, attributing the lead to the originating partner.

<Note>
  If the visitor did not arrive through a partner referral link, no tracking cookie is present and the lead is created without partner attribution. The call still succeeds — Kiflo simply records the lead without an associated partner.
</Note>

<Tip>
  Place the `kiflo('lead', ...)` call inside your form's submission handler, after you have validated the input but before redirecting the user. This ensures leads are reliably captured even if users close the tab immediately after submitting.
</Tip>
