> ## 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.

# Set Up and Install the Kiflo JS SDK on Your Website

> Install the Kiflo JS snippet on your website to start tracking partner referrals, then verify your setup and enable cross-subdomain cookie tracking.

The Kiflo JS SDK is a lightweight JavaScript snippet you embed in your website's `<head>`. Once installed, it automatically tracks every visitor who arrives through a partner's referral link and stores their referral code in a first-party browser cookie. You can then use the SDK's methods to attribute sign-ups, leads, and sales back to the right partner — no backend code required for most common workflows.

## Install the snippet

<Steps>
  <Step title="Copy your snippet from Kiflo">
    1. Log in to your Kiflo account.
    2. Click your name in the upper-right corner and select **Account**.
    3. In the left menu, click **Integration**.
    4. Copy the JavaScript snippet displayed on the page — it is pre-populated with **your own `apiKey`**, so you do not need to modify it.
  </Step>

  <Step title="Paste the snippet into your website">
    Paste the snippet inside the `<head>` tag of every page on your website. If you use a tag manager, you can deploy it through **Google Tag Manager** as a Custom HTML tag.

    ```javascript theme={null}
    var kjs = window.kjs || function (a) {
      var c = { apiKey: a.apiKey };
      var d = document;
      setTimeout(function () {
        var b = d.createElement("script");
        b.src = a.url || "https://cdn.kiflo.com/k.js", d.getElementsByTagName("script")[0].parentNode.appendChild(b)
      });
      return c;
    }({ apiKey: "YOUR_API_KEY" });
    ```

    Replace `YOUR_API_KEY` with the value from your Kiflo Integration settings (Kiflo pre-fills this for you when you copy the snippet directly from the dashboard).
  </Step>

  <Step title="Verify your installation">
    Go back to Kiflo and click **Verify your installation** in the Integration section. Kiflo will check whether the snippet is detected on your domain.

    If your URL is not yet on the authorized list but the snippet is detected, Kiflo will prompt you to add it to the list of authorized URLs. Authorize your domain to complete the setup.
  </Step>
</Steps>

Once the snippet is live, every visitor arriving through a partner referral link is automatically tracked.

## Advanced: cross-subdomain tracking

By default, Kiflo sets the tracking cookie on the exact domain where the snippet runs. If you host different parts of your funnel on separate subdomains (for example, a marketing site on `landing.example.com` and a sign-up form on `app.example.com`), you need the cookie to be accessible across all of them.

Use the `useDomain` parameter to pin the cookie to your root domain so every subdomain can read it:

```javascript theme={null}
var kjs = window.kjs || function (a) {
  var c = { apiKey: a.apiKey, useDomain: a.useDomain };
  var d = document;
  setTimeout(function () {
    var b = d.createElement("script");
    b.src = a.url || "https://cdn.kiflo.com/k.js", d.getElementsByTagName("script")[0].parentNode.appendChild(b)
  });
  return c;
}({ apiKey: "YOUR_API_KEY", useDomain: "example.com" });
```

Set `useDomain` to your root domain (e.g., `"example.com"`) — not a subdomain. Deploy this version of the snippet on **every** subdomain you want to participate in tracking.

<Note>
  Remember to update both `YOUR_API_KEY` and `"example.com"` in the snippet. If you copy the snippet from the Kiflo dashboard, the `apiKey` is already filled in — only add `useDomain` manually.
</Note>

## Cookie and GDPR

The Kiflo JS SDK stores a first-party cookie named `kfl_key` on your domain for up to **30 days**. This cookie tracks referral partner attribution. If your website serves visitors in the EU, update your Cookie Policy to include this cookie under the Functional / Tracking (referral attribution) category.

## Next steps

Now that the SDK is installed, connect your forms to Kiflo:

* [Create a Customer](/developers/js-sdk/create-customer) — attribute sign-ups to the source partner and trigger rewards on conversion.
* [Create a Lead](/developers/js-sdk/create-lead) — record demo requests and other qualified leads with their referring partner.
* [Create a Partner](/developers/js-sdk/create-partner) — connect your partner application form so new partners are created directly in Kiflo.
