> ## 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: Track New Customer Sign-Ups from Referrals

> Call kiflo('customer', ...) on sign-up to attribute new customers to their referring partner and automatically trigger partner rewards.

Call `kiflo('customer', ...)` each time a new user signs up on your website. Kiflo reads the referral tracking cookie that was set when the visitor first arrived through a partner link, and uses it to attribute the new customer to the correct partner. This attribution is what triggers any rewards or commissions you have configured for your partners.

## Syntax

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

The success callback receives Kiflo's response object. The error callback receives a description of what went wrong. Both callbacks are optional — omit them if you do not need to react to the result.

## Example

```javascript theme={null}
kiflo('customer', {
  properties: {
    email: 'john.doe@example.com',
    // your custom customer properties
  }
},
function(response) {
  // handle success
},
function(error) {
  // handle error
});
```

## Parameters

### CustomerObject

<ParamField body="properties" type="object" required>
  The properties of the customer as configured in your Kiflo [account properties](https://app.kiflo.com/account/properties). An `email` field is required inside this object. You can include any additional custom properties you have defined.

  ```json theme={null}
  {
    "email": "john.doe@example.com",
    "plan": "pro",
    "signupSource": "website"
  }
  ```
</ParamField>

## How Kiflo tracks partner referrals

When a visitor arrives on your website through a partner's unique referral link, Kiflo JS automatically writes the referral tracking code into a first-party browser cookie (`kfl_key`). The cookie persists for up to 30 days, so a visitor can return multiple times before signing up and still be correctly attributed.

When you call `kiflo('customer', ...)`, the SDK reads that cookie and sends the tracking code along with the customer's properties to Kiflo in a single request. No manual work is needed — cookie reading and attribution happen transparently.

<Note>
  The cookie is set on the visitor's browser, so `kiflo('customer', ...)` must be called from **client-side JavaScript** (i.e., in the browser) to work correctly. If you call it server-side, there is no browser context and no cookie to read.
</Note>

## Creating customers from backend code (API)

If your sign-up flow processes new users on the server rather than in the browser, you cannot call the JS SDK from your backend. Instead:

1. Use [`kiflo('getTrackingCode')`](/developers/js-sdk/tracking-code) in the browser to read the current referral tracking code.
2. Send that tracking code to your server alongside the rest of the sign-up data.
3. Call the [Kiflo REST API](https://docs-api.kiflo.com) from your backend to create the customer, passing the tracking code in the request so Kiflo can perform attribution.

<Tip>
  Sending the tracking code from the browser to your server is as simple as including it as a hidden field in your sign-up form, or as an extra field in your JSON sign-up payload.
</Tip>
