# Videos

> How often videos are started, how far people watch and on which pages. Your own players, YouTube and Vimeo.

Okidoki counts the videos on your site by itself: how often each one is started, how far people watch, and on which pages. It works for video players on your own pages (`<video>`) and for YouTube and Vimeo embeds. The card **Do people watch your videos?** shows up under **Reports** once a video has been started.

## How it works

On a page with a video, the script loads a small add-on, `v.js`, from next to itself. Pages without a video never load it, so the script stays under 1.5 KB. The add-on sends an event when a video:

| Event | When |
| --- | --- |
| `video_start` | Someone presses play |
| `video_25`, `video_50`, `video_75` | Playback passes a quarter, half and three quarters of the video |
| `video_complete` | The video plays to the end |

Each event is sent at most once per video and page view, with the video's name as the target. Background videos that play by themselves without sound are not counted.

## The report

| Tab | What it shows |
| --- | --- |
| **Videos** | Starts per video, the share watched to the end, and the page it is started on most |
| **Pages** | Starts per page, the share watched to the end, and the video started most there |

The sentence on top says it in words, like *Videos were started 214 times, and 38% of starts were watched to the end.* Through the API, MCP and Okidoki AI the `videos` report also gives the share of starts that reached 25%, 50% and 75%, and the starts and completion rate for the period before.

## Naming a video

Okidoki uses, in order: the `data-okidoki-video` attribute, the title YouTube or Vimeo gives the video, the `title` or `aria-label` of a `<video>`, and its file name.

```html
<video src="/tour.mp4" controls data-okidoki-video="Product tour"></video>
<iframe src="https://www.youtube-nocookie.com/embed/VIDEO_ID" data-okidoki-video="How it works"></iframe>
```

## A video as a goal

Under **Goals**, track the event `video_start` (*Started a video*) or `video_complete` (*Watched a video to the end*). Add a target, like `Product tour`, to count one video only. See [Goals](https://docs.okidoki.sh/goals).

## YouTube and Vimeo cookies

Okidoki saves nothing in the browser. The players from YouTube and Vimeo do set their own cookies, which is something to ask consent for. Avoid them:

- **YouTube**: embed from `youtube-nocookie.com` instead of `youtube.com`, like `https://www.youtube-nocookie.com/embed/VIDEO_ID`.
- **Vimeo**: add `dnt=1` to the player address, like `https://player.vimeo.com/video/VIDEO_ID?dnt=1`.

For YouTube to tell the page what is playing, the embed needs `enablejsapi=1`. The add-on adds it if it is missing, which reloads the embed once when the page opens. Add it yourself to skip that.

> [!NOTE]
> If you serve the script from your own address through a proxy, forward `v.js` next to `s.js` as well. The recipes in [Count visitors with ad blockers](https://docs.okidoki.sh/ad-blockers) do.

