---
title: "Toggle visitor analytics for a site"
method: PATCH
path: "/sites/{id}/analytics-enabled"
tags: ["Sites"]
---

# Toggle visitor analytics for a site

`PATCH /sites/{id}/analytics-enabled`

## Request

- Base URL: `https://api.nippy.host`
- URL: `https://api.nippy.host/sites/{id}/analytics-enabled`
- Auth: `bearer` (a scheme the document does not define)

Persists the owner preference and re-publishes the KV record so the worker starts or stops injecting the analytics script (and recording beacons) on the next request.

## Path parameters

- `id` string, required

## Request body

- UpdateSiteAnalyticsEnabledDto
  - `analyticsEnabled` boolean, required: When true, the worker injects the analytics script and records pageview/engagement beacons for the site. When false, analytics is turned off on the next request.

## Response `200`

- APISiteAnalyticsEnabledResponse
  - `id` string, required: Site UUID
  - `analyticsEnabled` boolean, required: Whether visitor analytics is enabled for this site.

## Other responses

- `400`: Invalid request body
- `401`: Not authenticated
- `403`: You do not own this site
- `404`: Site not found

---

[API](https://skmtc.dev/nippy/apis/nippy-backend-api.md) · [All operations](https://skmtc.dev/nippy/apis/nippy-backend-api/llms.txt) · [OpenAPI document](https://skmtc.dev/nippy/apis/nippy-backend-api/revisions/7ab23f040a55?raw)
