---
title: "Analytics"
description: "How connected Docs Cloud projects store runtime analytics events"
canonical_url: "https://docs.farming-labs.dev/docs/cloud/analytics"
markdown_url: "https://docs.farming-labs.dev/docs/cloud/analytics.md"
last_updated: "2018-10-20"
agent:
  tokenBudget: 900
  task: "Connect a docs runtime to Docs Cloud analytics without exposing user-authored inputs by default."
  outcome: "Runtime events are attributed to the intended Docs Cloud project and appear in its analytics dashboard."
  appliesTo:
    framework:
      - "nextjs"
      - "tanstackstart"
      - "sveltekit"
      - "astro"
      - "nuxt"
    version:
      - ">=0.2.60"
    package:
      - "@farming-labs/docs"
  prerequisites:
    - "A Docs Cloud workspace has an imported project or custom analytics project."
    - "The dashboard-provided project ID is available for the runtime environment."
    - "Consent and retention policies are defined before enabling includeInputs."
  files:
    - ".env.local"
    - "docs.config.ts"
    - "docs.config.tsx"
    - "src/lib/docs.config.ts"
    - "docs.json"
  commands:
    - run: "pnpm dlx @farming-labs/docs cloud check --analytics --no-network"
      description: "Validate local analytics configuration and required environment variables."
  sideEffects:
    - "Enabling Cloud analytics sends runtime usage events for the configured project."
    - "Enabling includeInputs can send raw search, Ask AI, feedback, or copy inputs."
  verification:
    - run: "pnpm dlx @farming-labs/docs cloud check --analytics --no-network"
      expect: "The analytics runtime, Cloud setting, and project environment checks pass."
    - description: "Trigger a test page view and confirm the event is attributed to the expected project in Docs Cloud."
  rollback:
    - "Disable cloud.analytics or set the documented analytics-enabled environment flag to false."
    - "Remove the project ID and analytics key from the runtime environment when disconnecting the site."
  failureModes:
    - symptom: "Events do not appear in the dashboard."
      resolution: "Copy the project ID from Docs Cloud again and use the framework-specific public or server environment variable documented on this page."
    - symptom: "User-authored text appears unexpectedly."
      resolution: "Set includeInputs to false and review the project consent and retention policy."
---

<!-- farming-labs:agent-contract:start -->
## Agent Contract

Task: Connect a docs runtime to Docs Cloud analytics without exposing user-authored inputs by default.
Outcome: Runtime events are attributed to the intended Docs Cloud project and appear in its analytics dashboard.

### Applies To

- Framework: `nextjs`, `tanstackstart`, `sveltekit`, `astro`, `nuxt`
- Version: `>=0.2.60`
- Package: `@farming-labs/docs`

### Prerequisites

- A Docs Cloud workspace has an imported project or custom analytics project.
- The dashboard-provided project ID is available for the runtime environment.
- Consent and retention policies are defined before enabling includeInputs.

### Files

- `.env.local`
- `docs.config.ts`
- `docs.config.tsx`
- `src/lib/docs.config.ts`
- `docs.json`

### Commands

- `pnpm dlx @farming-labs/docs cloud check --analytics --no-network` — Validate local analytics configuration and required environment variables.

### Side Effects

- Enabling Cloud analytics sends runtime usage events for the configured project.
- Enabling includeInputs can send raw search, Ask AI, feedback, or copy inputs.

### Verification

- Run `pnpm dlx @farming-labs/docs cloud check --analytics --no-network`
  - Expected: The analytics runtime, Cloud setting, and project environment checks pass.
- Trigger a test page view and confirm the event is attributed to the expected project in Docs Cloud.

### Rollback

- Disable cloud.analytics or set the documented analytics-enabled environment flag to false.
- Remove the project ID and analytics key from the runtime environment when disconnecting the site.

### Failure Modes

- Events do not appear in the dashboard. — Recovery: Copy the project ID from Docs Cloud again and use the framework-specific public or server environment variable documented on this page.
- User-authored text appears unexpectedly. — Recovery: Set includeInputs to false and review the project consent and retention policy.
<!-- farming-labs:agent-contract:end -->

# Analytics

## Analytics task

Task: Connect a docs runtime to Docs Cloud analytics without exposing user-authored inputs by default.

Expected result: Runtime events are attributed to the intended Docs Cloud project and appear in its analytics dashboard.

## Analytics prerequisites

- A Docs Cloud workspace has an imported project or custom analytics project.
- The dashboard-provided project ID is available for the runtime environment.
- Consent and retention policies are defined before enabling includeInputs.
- Applies to framework nextjs, tanstackstart, sveltekit, astro, nuxt; version >=0.2.60; package @farming-labs/docs.

## Analytics verification

- Run pnpm dlx @farming-labs/docs cloud check --analytics --no-network. Expected: The analytics runtime, Cloud setting, and project environment checks pass.
- Trigger a test page view and confirm the event is attributed to the expected project in Docs Cloud.
- Failure: Events do not appear in the dashboard.
- Recovery: Copy the project ID from Docs Cloud again and use the framework-specific public or server environment variable documented on this page.
- Rollback: Disable cloud.analytics or set the documented analytics-enabled environment flag to false.

## Analytics agent guidance

Use this page when the user asks about this topic: Docs Cloud analytics, project identity, managed Cloud analytics delivery, event storage, dashboard analytics, includeInputs privacy, and customer onEvent callbacks.
Keep answers technical and avoid exposing internal transport details as public setup steps. If the user asks how to deploy a hosted preview, point to /docs/cloud/deploy. If the user asks about runtime event options outside Cloud, point to /docs/customization/analytics.

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
Docs-scoped sitemap: [/docs/sitemap.md](/docs/sitemap.md).
Well-known sitemap: [/.well-known/sitemap.md](/.well-known/sitemap.md).
