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

# Analytics

Built-in analytics for tracking page views, search queries, and reader engagement on your documentation site.

## Overview

HolyDocs includes built-in analytics that track how readers interact with your documentation. No third-party scripts are required — analytics are collected by a lightweight tracking script served from your documentation domain.

## What is Tracked

| Metric | Description |
|---|---|
| **Page views** | Total and unique page views per page |
| **Search queries** | What readers search for and which results they click |
| **Time on page** | Average time spent reading each page |
| **Navigation paths** | How readers move between pages |
| **Referrers** | Where traffic comes from (search engines, direct, etc.) |
| **Feedback** | Thumbs up/down ratings and written feedback per page |
| **AI interactions** | Assistant questions asked and search queries |

## Dashboard

Access analytics from the **Analytics** page in your project sidebar. The dashboard is organized into four sections:

### Overview

The overview tab provides a high-level summary for the selected time period (7d, 30d, 90d, or custom range):

- **Total page views** — aggregate across all pages, with trend comparison to the previous period
- **Unique visitors** — deduplicated by anonymous session ID (no cookies or fingerprinting)
- **Top pages** — the 10 most visited pages ranked by view count
- **Bounce rate** — percentage of visitors who leave after viewing only one page
- **Average session duration** — how long readers spend browsing your docs in a single session

### Pages

Drill into per-page analytics:

- **View count** — total and unique views for each page
- **Average time on page** — how long readers spend on each page (useful for identifying confusing or underperforming content)
- **Feedback score** — aggregate thumbs up/down ratio per page
- **Scroll depth** — how far down the page readers scroll on average (25%, 50%, 75%, 100% markers)

### Search

Understand what readers are looking for:

- **Top queries** — most frequently searched terms
- **Click-through rate** — percentage of searches that result in a page click
- **Zero-result queries** — searches that returned no results (a signal to add or improve content)
- **Query-to-page mapping** — which pages are most often found via search

### AI

Track AI assistant and search usage:

- **Total messages** — number of assistant conversations started
- **Common questions** — most frequently asked questions, grouped by topic
- **Resolution rate** — percentage of conversations where the reader did not need to ask a follow-up
- **Satisfaction** — optional thumbs up/down on assistant responses

## Tracking Script

HolyDocs injects a lightweight tracking script on every page. The script:

- Is less than 2KB gzipped
- Runs asynchronously and does not block page rendering
- Sends events to `https://api.holydocs.com/api/v1/analytics`
- Respects Do Not Track (DNT) browser settings
- Does not use cookies or fingerprinting

The built-in analytics are privacy-friendly by design. No personal data is collected, no cookies are set, and all data is aggregated at the page level.

## Third-Party Integrations

In addition to built-in analytics, HolyDocs supports 15+ third-party analytics and monitoring integrations. Configure them in `docs.json`:

```json
{
  "integrations": {
    "ga4": {
      "measurementId": "G-XXXXXXXXXX"
    },
    "posthog": {
      "apiKey": "phc_xxxxxxxxxxxx",
      "apiHost": "https://app.posthog.com"
    },
    "segment": {
      "writeKey": "xxxxxxxxxxxx"
    }
  }
}
```

### Supported Integrations

**Google Analytics 4** GA4 measurement ID
  **PostHog** Product analytics
  **Segment** Customer data platform
  **Amplitude** Behavioral analytics
  **Mixpanel** Product analytics
  **Plausible** Privacy-friendly analytics
  **Fathom** Simple analytics
  **Heap** Digital insights
  **Intercom** Customer messaging
  **Crisp** Live chat
  **Hotjar** Heatmaps and recordings
  **Koala** Revenue intelligence
  **Clearbit** Enrichment
  **LogRocket** Session replay
  **Sentry** Error tracking

### Configuration Examples

**Google Analytics 4**

```json
    {
      "integrations": {
        "ga4": {
          "measurementId": "G-XXXXXXXXXX"
        }
      }
    }
    ```
    Injects the GA4 `gtag.js` script. Page views are tracked automatically. Custom events from HolyDocs (search queries, feedback, assistant usage) are also forwarded as GA4 events.
  **PostHog**

```json
    {
      "integrations": {
        "posthog": {
          "apiKey": "phc_xxxxxxxxxxxx",
          "apiHost": "https://app.posthog.com"
        }
      }
    }
    ```
    Enables PostHog autocapture for clicks, page views, and form submissions. Set `apiHost` to your self-hosted instance URL if applicable.
  **Plausible**

```json
    {
      "integrations": {
        "plausible": {
          "domain": "docs.yourcompany.com"
        }
      }
    }
    ```
    Lightweight, privacy-friendly analytics. No cookies, fully GDPR compliant. The script is loaded from Plausible's CDN (`plausible.io/js/script.js`).
  **Amplitude**

```json
    {
      "integrations": {
        "amplitude": {
          "apiKey": "your-amplitude-api-key"
        }
      }
    }
    ```
    Tracks page views and search events in Amplitude. Use Amplitude's dashboard to build funnels and cohorts around documentation engagement.
  **Segment**

```json
    {
      "integrations": {
        "segment": {
          "writeKey": "your-segment-write-key"
        }
      }
    }
    ```
    Routes all HolyDocs analytics events through Segment, allowing you to forward data to any of Segment's 300+ destinations without changing your docs configuration.

## Custom Events

In addition to automatic tracking, HolyDocs fires custom events that you can use in your analytics pipeline:

| Event | Fired When | Payload |
|---|---|---|
| `docs.page_view` | Reader visits a page | `{ path, title, referrer }` |
| `docs.search` | Reader performs a search | `{ query, resultCount }` |
| `docs.search_click` | Reader clicks a search result | `{ query, resultPath, position }` |
| `docs.feedback` | Reader submits page feedback | `{ path, rating, comment }` |
| `docs.assistant_open` | Reader opens the AI assistant | `{ path }` |
| `docs.assistant_message` | Reader sends a message to the assistant | `{ questionLength }` |
| `docs.code_copy` | Reader copies a code block | `{ path, language }` |
| `docs.version_switch` | Reader switches documentation version | `{ from, to }` |
| `docs.language_switch` | Reader changes language | `{ from, to }` |

These events are forwarded to all configured third-party integrations automatically. They are also available in the built-in analytics dashboard.

## Feedback Collection

Enable per-page feedback with thumbs up/down ratings:

Readers see a "Was this page helpful?" prompt at the bottom of each page. Feedback data is available in the analytics dashboard and can trigger outbound webhooks.

## OG Images

HolyDocs automatically generates Open Graph images for social sharing. When your documentation pages are shared on Twitter, Slack, or Discord, they display a branded preview card with the page title and description.

OG images are generated at:

```
https://api.holydocs.com/api/v1/og-image/PROJECT_ID?path=/quickstart
```

## SEO

Configure SEO settings in `docs.json`:

```json
{
  "seo": {
    "metatags": {
      "og:site_name": "My Docs",
      "twitter:site": "@mycompany"
    },
    "indexing": "navigable"
  }
}
```

| Option | Values | Description |
|---|---|---|
| `indexing` | `navigable` \| `all` | Only index pages in navigation, or all pages |

HolyDocs automatically adds JSON-LD structured data to every page for improved search engine visibility.