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

# Analytics

> Track views, leads, and link clicks across your demo videos and domains.

Demomatic automatically tracks three engagement metrics for every demo video you publish. You can view stats at the individual video level or rolled up across an entire domain.

## Metrics

<CardGroup cols={3}>
  <Card title="Unique views" icon="eye">
    Counts each distinct viewer once. Demomatic identifies logged-in viewers by user ID and anonymous viewers by a hashed IP address.
  </Card>

  <Card title="Leads" icon="user-plus">
    Form submissions captured when a viewer fills in your CTA form. Each lead includes the submitted field values.
  </Card>

  <Card title="Link clicks" icon="arrow-up-right-from-square">
    Clicks on external CTA links, such as a Calendly or booking URL. Each viewer is counted once per video.
  </Card>
</CardGroup>

<Note>
  `link_clicks` is always `0` for videos with a form CTA. `leads` is always `0` for videos with an external link CTA. Both fields are present in every response for consistency.
</Note>

## How view tracking works

The video player automatically calls `POST /videos/:id/view` when a viewer watches a video. No authentication is required — the endpoint works for both logged-in and anonymous viewers. Calling it more than once for the same viewer has no effect; the backend deduplicates by viewer identity.

## Viewing stats

<Tabs>
  <Tab title="Per video">
    Retrieve counts for a single video. Requires authentication.

    ```http theme={null}
    GET /videos/:video_id/stats
    ```

    **Response**

    ```json theme={null}
    {
      "data": {
        "views": 142,
        "leads": 18,
        "link_clicks": 0
      }
    }
    ```
  </Tab>

  <Tab title="Per domain">
    Retrieve aggregate counts across all videos in a domain. Requires authentication.

    ```http theme={null}
    GET /domains/:id/stats
    ```

    **Response**

    ```json theme={null}
    {
      "data": {
        "views": 980,
        "leads": 74,
        "link_clicks": 12
      }
    }
    ```
  </Tab>

  <Tab title="API key">
    Use your API key to fetch stats programmatically without a user session.

    ```http theme={null}
    GET /v1/videos/:id/stats
    GET /v1/domains/:domain_id/stats
    ```

    Both endpoints return the same `{ data: { views, leads, link_clicks } }` shape. See [API keys](/guides/api-keys) for authentication details.
  </Tab>
</Tabs>

## Stats fields

<ResponseField name="views" type="number">
  Total unique viewers for the video or domain.
</ResponseField>

<ResponseField name="leads" type="number">
  Total CTA form submissions. Only non-zero when `cta_type` is `form`.
</ResponseField>

<ResponseField name="link_clicks" type="number">
  Total unique clicks on the external CTA link. Only non-zero when `cta_type` is `external_link`.
</ResponseField>
