# Quickstart

Add one script tag on your site. The script records the view, the dwell, and the scroll. You run the Worker on your own Cloudflare account. Worker setup is on Self-hosting.

## Add the script

Serve the page script from your site and load it on each page you count.

```html
<script src="/visit.js" defer></script>
```

> Scope: EMBED | Expect: HTTP 204 (Beacon posts to /api/hit and /api/engaged)

It posts to `/api/hit` and `/api/engaged` on the same origin. Use `/visit.js` when the file sits at the site root.

## View, dwell, and scroll

On load, `/api/hit` gets the view: the path, a `ref` or `utm_source` tag when the link has one, and the referring host.

Dwell is how long the page was in view, in milliseconds. Scroll is the deepest point reached, from 0 to 100. Both go to `/api/engaged` when the page is hidden or the reader leaves.

The script sets no cookie. The view id stays in the page's memory. A browser that sends Do Not Track sends nothing. What a view row keeps is on [Data and privacy](/docs/data-and-privacy).

## Name the page

The page may pass a label, a title, and a publish time via `<meta name="kokumi:label">`, `<meta name="kokumi:publishedAt">`, and `<meta name="kokumi:title">` tags read by `visit.js` onto that same `/api/hit` body.

```json
{
  "label": "post",
  "title": "How we run a crew of AI agents",
  "publishedAt": "2026-10-18T16:00:00Z"
}
```

> Scope: EMBED | Expect: HTTP 204 (Named post record stored alongside view)

The label is `post`, `product`, or `offer`. `publishedAt` is the publish time the page sends, as an ISO time with a zone. Kokumi stores that as its own record for the path. A page that sends nothing stays a page. A title is kept when a label or a publish time comes with it. A later request that omits a field leaves the stored value in place.

The view, the dwell, and the scroll are recorded either way. The named record is a separate row.

Day 1, day 7, and day 30 against your own median are scored in the CLI and dashboard. [Post scorecard](/features/post-scorecard).

## Next

Read the counts from the [API reference](/docs/api). Schema steps for a deploy today are in the [repository README](https://github.com/mackenziebowes/kokumi#readme). A one-click deploy button is planned. [Deploy](/deploy).
