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

# Client-side click tracking

> Understand automatic redirect attribution and the optional trackClick method.

Most integrations do **not** need to call `trackClick()`.

When a visitor opens a conversion-enabled Biqli short link, Biqli records the redirect click and forwards its click ID as `bq_id`. The browser SDK captures that value automatically.

```text theme={null}
https://biq.li/example
    -> https://www.example.com/signup?bq_id=qPa4lSpsKj3B
```

Confirm the captured value:

```ts theme={null}
biqli.getClickId();
```

## When to use trackClick

Use `trackClick()` only when your browser application must create a click for a known Biqli link without first following the normal short-link redirect.

First enable **Client-side click tracking** in **Workspace settings -> Tracking**.

```ts theme={null}
const result = await biqli.trackClick({
  domain: 'biq.li',
  key: 'example',
  url: window.location.href,
  eventId: 'landing:view:session_9381',
});

console.log(result.clickId);
```

| Field      | Required | Meaning                                                                |
| :--------- | :------- | :--------------------------------------------------------------------- |
| `domain`   | Yes      | Short-link hostname without a protocol                                 |
| `key`      | Yes      | Link alias or generated key                                            |
| `url`      | No       | Page URL associated with the client click; defaults to the current URL |
| `referrer` | No       | Referring URL; defaults to `document.referrer`                         |
| `eventId`  | No       | Stable identifier used for retry safety                                |

The SDK stores the returned click ID using the configured first-click or last-click model.

## Common errors

* `client_click_tracking_disabled`: enable the setting for this workspace.
* `origin_not_allowed`: add the exact browser hostname and save it.
* `resource_not_found`: the domain and key do not resolve to an eligible link in this workspace.
* `idempotency_conflict`: the same `eventId` was reused with different input.

<Note>
  Do not call `trackClick()` after every page view. Single-page navigation capture updates stored attribution from URL parameters; it does not create a new click event by itself.
</Note>
