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

# Tracking configuration

> Turn on optional tracking features for a site, and read the public remote config the browser tracker itself fetches.

Turn on optional tracking features for a site, and read the public remote config the browser tracker itself fetches. A site is addressed by `{siteKey}` (UUID or domain) for the enable endpoints below. See [Conventions](/api/conventions) for the base URL, headers, and error conventions shared by every authenticated endpoint.

Each enable endpoint flips one boolean flag on the `Site` model and invalidates the tracker's remote config cache, then returns the updated site through the same `SiteResource` used by [Sites](/api/sites). All three are additive, idempotent toggles — calling one that is already on is a no-op that still returns `200 OK`.

| Feature        | Endpoint                                          | Flag                   |
| -------------- | ------------------------------------------------- | ---------------------- |
| Web Vitals     | `POST /api/sites/{siteKey}/performance/enable`    | `track_web_vitals`     |
| Error tracking | `POST /api/sites/{siteKey}/error-tracking/enable` | `track_errors`         |
| Session replay | `POST /api/sites/{siteKey}/replays/enable`        | `track_session_replay` |

Session replay's enable endpoint is documented in full in [Session replay](/api/session-replay#enable-session-replay) — it shares this same pattern and response shape, so it isn't duplicated here.

### Enable Web Vitals

```http theme={null}
POST /api/sites/{siteKey}/performance/enable
```

Route name: `api.sites.performance.enable`. Turns on `track_web_vitals` so the tracker starts sending Core Web Vitals measurements for the site.

**Path parameters**

| Parameter | Type   | Required | Description          |
| --------- | ------ | -------- | -------------------- |
| `siteKey` | string | Yes      | Site UUID or domain. |

**Response** — the updated site. Status: `200 OK`.

<CodeGroup>
  ```bash title="curl" theme={null}
  curl -X POST "https://clickbase.so/api/sites/example.com/performance/enable" \
    -H "Authorization: Bearer {token}" \
    -H "Accept: application/json"
  ```

  ```javascript title="JavaScript" theme={null}
  await fetch('https://clickbase.so/api/sites/example.com/performance/enable', { method: 'POST', headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' } })
  ```

  ```python title="Python" theme={null}
  requests.post('https://clickbase.so/api/sites/example.com/performance/enable', headers={'Authorization': f'Bearer {token}', 'Accept':'application/json'})
  ```
</CodeGroup>

### Enable error tracking

```http theme={null}
POST /api/sites/{siteKey}/error-tracking/enable
```

Route name: `api.sites.error-tracking.enable`. Turns on `track_errors` so the tracker starts reporting unhandled JS errors for the site.

**Path parameters**

| Parameter | Type   | Required | Description          |
| --------- | ------ | -------- | -------------------- |
| `siteKey` | string | Yes      | Site UUID or domain. |

**Response** — the updated site. Status: `200 OK`.

<CodeGroup>
  ```bash title="curl" theme={null}
  curl -X POST "https://clickbase.so/api/sites/example.com/error-tracking/enable" \
    -H "Authorization: Bearer {token}" \
    -H "Accept: application/json"
  ```

  ```javascript title="JavaScript" theme={null}
  await fetch('https://clickbase.so/api/sites/example.com/error-tracking/enable', { method: 'POST', headers: { Authorization: `Bearer ${token}`, Accept: 'application/json' } })
  ```

  ```python title="Python" theme={null}
  requests.post('https://clickbase.so/api/sites/example.com/error-tracking/enable', headers={'Authorization': f'Bearer {token}', 'Accept':'application/json'})
  ```
</CodeGroup>

### Enable endpoint response fields

All three enable endpoints (`performance/enable`, `error-tracking/enable`, `replays/enable`) return the same `SiteResource` as the site-management endpoints — see the authoritative [Response fields](/api/sites#response-fields) table in [Sites](/api/sites) for the full field set.

### Public tracking config

```http theme={null}
GET /api/tracking-config/{trackingKey}
```

Route name: `api.tracking-config.show`. The **public, unauthenticated** remote config the browser tracker script fetches before its first pageview — this is where the toggles set by the enable endpoints above actually take effect client-side. `{trackingKey}` is the site's tracking key (the same value as `data-site-id` on the install snippet), not an OAuth-authenticated `{siteKey}`. Rate-limited on the shared `tracking` bucket (kept separate from `/api/collect` so config polls can't starve ingestion).

**Path parameters**

| Parameter     | Type          | Required | Description                               |
| ------------- | ------------- | -------- | ----------------------------------------- |
| `trackingKey` | string (uuid) | Yes      | The site's tracking key (`data-site-id`). |

**Response** — a flat object:

| Field                        | Type   | Description                                                                                                                                             |
| ---------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tracking_mode`              | string | `cookieless` or `cookie`.                                                                                                                               |
| `track_initial_pageview`     | bool   | Whether the tracker auto-fires a pageview on load.                                                                                                      |
| `track_spa_navigation`       | bool   | Whether SPA route changes are tracked as pageviews.                                                                                                     |
| `track_url_params`           | bool   | Whether URL query params are recorded.                                                                                                                  |
| `track_outbound_links`       | bool   | Autocapture: outbound link clicks.                                                                                                                      |
| `track_file_downloads`       | bool   | Autocapture: file downloads.                                                                                                                            |
| `track_button_clicks`        | bool   | Autocapture: button clicks.                                                                                                                             |
| `track_form_submits`         | bool   | Autocapture: form submits.                                                                                                                              |
| `track_copy`                 | bool   | Autocapture: copy events.                                                                                                                               |
| `track_errors`               | bool   | Whether error tracking is enabled (set via [Enable error tracking](#enable-error-tracking)).                                                            |
| `track_web_vitals`           | bool   | Whether Web Vitals tracking is enabled (set via [Enable Web Vitals](#enable-web-vitals)).                                                               |
| `track_session_replay`       | bool   | Whether session replay is enabled **and** the team can currently ingest events (a lapsed subscription forces this `false` even if the site flag is on). |
| `session_replay_sample_rate` | int    | Percentage of sessions recorded, 0–100.                                                                                                                 |

Status: `200 OK`. An unknown `trackingKey` returns `404 Not Found` with `{ "message": "Not found." }`.

<CodeGroup>
  ```bash title="curl" theme={null}
  curl "https://clickbase.so/api/tracking-config/{trackingKey}" \
    -H "Accept: application/json"
  ```

  ```javascript title="JavaScript" theme={null}
  await fetch(`https://clickbase.so/api/tracking-config/${trackingKey}`, { headers: { Accept: 'application/json' } })
  ```

  ```python title="Python" theme={null}
  requests.get(f'https://clickbase.so/api/tracking-config/{tracking_key}', headers={'Accept': 'application/json'})
  ```
</CodeGroup>
