# set_analytics_enabled

Source: https://modulify.ai/docs/api/analytics/set-analytics-enabled

Turns visitor analytics collection on or off for a site, reaching visitors only once the site is published again.

- Title: Turn visitor analytics on or off
- Scope: `sites:write`
- Access: Makes changes
- Endpoint: `POST /v1/set_analytics_enabled`

Turning it off stops new visitors being counted, but a live site keeps collecting until it is published again. Existing history is untouched either way. The response carries `analyticsEnabled` with the setting as it now stands.

The tool tells the client to reach for it when you ask to stop tracking, and always to tell you about the publish step, because otherwise you would believe collection stopped when it has not. Any member of the workspace can change it, and it makes no analytics lookup. See [Collection](https://modulify.ai/docs/grow/analytics#collection).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/set_analytics_enabled`, sending the inputs below as a JSON object. The token needs the `sites:write` scope.

It makes changes, so send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

```bash
curl -X POST https://api.modulify.ai/v1/set_analytics_enabled \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","enabled":true}'
```

Over MCP, the same method is the [set_analytics_enabled tool](https://modulify.ai/docs/mcp/analytics/set-analytics-enabled).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `enabled` | boolean | Yes | True to collect visitors, false to stop. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.