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

# Server-side tracking

> Track clicks, customers and payments from your backend, with no browser script.

Use this when tolt.js can't run: mobile apps, redirect links you host, or sales-led deals. Three API calls replace the script.

Visitorapp or linkYour serverbackendTolt/v2 API*1*?ref=sam*2*POST /v2/clicks*3*clk\_3nVb… part\_8fKq…*4*signup jane\@example.com*5*POST /v2/customers*6*cus\_Q7wR…*7*POST /v2/transactions*8*txn\_Hc5d…*9*comm\_2nV8… 1470

Good fits: mobile apps, redirect links, and sales-led deals where nobody clicks a link in a browser.

**1. Record the click**

When someone arrives through a partner link, send what you know: the `param` and `value` from the URL (or a `link_id` / `partner_id`), plus optional `page`, `referrer`, `country` (ISO 2) and `device`. Keep the returned `id` and `partner_id` with the visitor, like a cookie would.

```ts TypeScript theme={"system"}
import { ToltApiClient } from "@tolt/api";

const tolt = new ToltApiClient({ token: process.env.TOLT_API_KEY! });

const { data: click } = await tolt.clicks.create({
  param: "ref",
  value: "sam",
  page: "https://acme.com/pricing?ref=sam",
  country: "US",
  device: "mobile",
});
// click.id -> "clk_...", click.partner_id -> "part_..."
```

```python Python theme={"system"}
import os
from tolt import ToltApi

client = ToltApi(token=os.environ["TOLT_API_KEY"])

click = client.clicks.create(
    param="ref",
    value="sam",
    page="https://acme.com/pricing?ref=sam",
    country="US",
    device="mobile",
).data
# click.id -> "clk_...", click.partner_id -> "part_..."
```

```bash cURL theme={"system"}
curl -X POST https://platform.tolt.com/v2/clicks \
  -H "Authorization: Bearer $TOLT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "param": "ref",
    "value": "sam",
    "page": "https://acme.com/pricing?ref=sam",
    "country": "US",
    "device": "mobile"
  }'
```

**2. Create the customer**

At signup, bind the user to the partner. `partner_id` (or `link_id`) is required. `click_id` links the signup to that exact click. Store the returned `cus_...` id on your user.

```ts TypeScript theme={"system"}
const { data: customer } = await tolt.customers.create({
  email: "jane@example.com",
  customer_id: "user_1042",
  partner_id: click.partner_id,
  click_id: click.id,
});
```

```python Python theme={"system"}
customer = client.customers.create(
    email="jane@example.com",
    customer_id="user_1042",
    partner_id="part_8fKq2LmZx7RtYw3nVbHc5dPj",
    click_id="clk_3nVbHc5dPj8fKq2LmZx7RtYw",
).data
```

```bash cURL theme={"system"}
curl -X POST https://platform.tolt.com/v2/customers \
  -H "Authorization: Bearer $TOLT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "jane@example.com",
    "customer_id": "user_1042",
    "partner_id": "part_8fKq2LmZx7RtYw3nVbHc5dPj",
    "click_id": "clk_3nVbHc5dPj8fKq2LmZx7RtYw"
  }'
```

**3. Record each payment**

On every successful charge, renewals included. Amounts are in the smallest unit of your program's currency (cents for USD). See [Record payments](https://docs.tolt.com/tracking/payments.md) for refunds and lookups.

```ts TypeScript theme={"system"}
await tolt.transactions.create({
  customer_id: customer.id,
  amount: 4900,
  charge_id: "ch_3Qf8x2aBcD",
});
```

```python Python theme={"system"}
client.transactions.create(
    customer_id=customer.id,
    amount=4900,
    charge_id="ch_3Qf8x2aBcD",
)
```

```bash cURL theme={"system"}
curl -X POST https://platform.tolt.com/v2/transactions \
  -H "Authorization: Bearer $TOLT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cus_Q7wRt2YxLm9KfZ3nPb8HcV4d",
    "amount": 4900,
    "charge_id": "ch_3Qf8x2aBcD"
  }'
```

> [!TIP]
>
> Sales-led deal with no click at all? Skip step 1 and create the customer with the partner's `partner_id` directly.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.