Skip to Content

Views, watch time and unique viewers

Read how often your videos are watched, for how long and by how many people, counted by ClipMux's delivery with no player beacon.

ClipMux counts playback where it serves it. Every view, every segment of watch time and every byte comes from delivery's own requests, so there is no analytics script to add to your pages and nothing for a viewer's ad blocker to stop. Your backend reads the numbers from the API; the server's owner sees them under Analytics in the dashboard.

Before you start

  • An API key with the analytics:read scope. Keys don't have it by default, including the one init makes; the server's owner adds it to a new key on the server:

    clipmux admin create-key --app "My app" --scopes uploads:write,assets:read,assets:write,analytics:read

    The owner can also create one with POST /v1/apps/{id}/api-keys and "scopes" in the body.

  • For unique viewers, tokens signed with a viewer ID; see below.

Read the numbers

import { ClipMux } from '@clipmux/node'

const clipmux = new ClipMux({ apiKey: process.env.ANALYTICS_API_KEY })

const app = await clipmux.analytics.get('30d') // every video of the key's app
const one = await clipmux.analytics.asset('ast_…', '7d') // one video

range is 24h, 7d, 30d or 90d; anything else is 400 invalid_request. GET /v1/analytics covers the key's own app. GET /v1/analytics/assets/{id} covers one of its videos, and a deleted video keeps its history.

{
  "totals": { "views": 1840, "watch_seconds": 302400, "unique_viewers": 412, "bytes_delivered": 98123456789 },
  "previous": { "views": 1502, "watch_seconds": 251000, "unique_viewers": null, "bytes_delivered": 80211000000 },
  "series": [{ "t": "2026-11-03T00:00:00Z", "views": 260, "watch_seconds": 43100, "bytes_delivered": 14000000000 }],
  "top_assets": [{ "asset_id": "ast_…", "title": "Lesson 42", "views": 310, "watch_seconds": 61000, "bytes_delivered": 17000000000 }],
  "storage": { "source_bytes": 524288000, "media_bytes": 2147483648, "total_bytes": 2671771648 },
  "collecting": { "builtin": true, "edge": "not_used" }
}
FieldWhat it is
totalsThe range's views, watch time in seconds, unique viewers and bytes. They include deleted videos' history.
previousThe same for the same length of time immediately before, to show a change.
seriesOne bucket per hour for 24h, per UTC day otherwise, oldest first, with empty buckets as zeros. t is the bucket's start. The last bucket is the current one, so it's partial.
top_assetsUp to 10 live videos, by views (and bytes when sampled views read zero). Not in the one-video response. A title may be missing.
storageCurrent storage taken across live sources (source_bytes), encoded outputs and tracks (media_bytes), and their sum (total_bytes). Zeros for deleted videos.
collectingWhere counts come from and edge pull health; see Edge counts.

What counts

  • A view is one master.m3u8 served. A player loads the master once when it starts, so a view is one play start. A viewer who reloads the page makes another view.
  • Watch time is 6 seconds for each audio segment served (or video segment, for a video with no audio). It counts what was fetched, not what was watched, so it overcounts by the player's buffer ahead: a viewer who stops after 10 seconds may have fetched 30.
  • Bytes are every body delivery sent.

Only successful answers count; refusals never do. Dashboard previews, library posters and the server's setup test aren't counted. Plays through share links are.

Unique viewers

ClipMux doesn't know who your viewers are. To count them, put a stable ID for each viewer in the playback token's vid claim:

// clipmuxHandler's playback callback
return { viewerId: user.id }

// or when you sign a token yourself
await clipmux.playback.token('pid_…', { viewerId: user.id })

For anonymous viewers, use a random ID you keep in their session. ClipMux stores only a keyed hash of vid, never the ID itself. unique_viewers counts distinct viewers by hour for 24h (matching exact [start, stop) and previous windows) and by UTC day for longer ranges, excluding poster requests, and is null when no view in the range carried a vid.

Nothing in analytics stores an IP address, User-Agent, referrer, token or raw viewer ID.

How long numbers are kept

  • Hourly counts, behind the 24h range: 14 days.
  • Daily counts and viewer hashes: 180 days, enough for two 90d ranges.

Older numbers are deleted.

Edge counts

With Cloudflare edge delivery, most requests never reach the ClipMux server. The Cloudflare Worker counts them instead, and the server pulls those counts in every 5 minutes once the owner connects edge analytics. collecting.edge says which applies:

collecting.edgeMeaning
not_usedNo Cloudflare delivery. The server counts everything.
not_connectedCloudflare delivers, but its counts aren't pulled in, so most plays are missing.
connectedEdge counts are pulled in. The last few minutes appear on the next pull.

Leaves your servers

With Cloudflare delivery, Cloudflare serves your viewers, and the Worker records each counted request in Cloudflare's Analytics Engine: the project, app, video and playback IDs, the kind of request, the views, watch time and bytes, and the keyed viewer hash. The ClipMux server reads them back with a read-only token.

Check it works

Play a video for a minute with a token that carries a vid, then:

curl -s 'https://video.example.com/v1/analytics/assets/ast_…?range=24h' \
  -H "Authorization: Bearer $ANALYTICS_API_KEY"

totals.views is at least 1 and unique_viewers at least 1. Counts reach Postgres within about 15 seconds.

  • 403 insufficient_scope: the key lacks analytics:read.
  • 404 not_found: the video belongs to another app.
  • unique_viewers is null: no token in the range had a vid.

Next

On this page