# Web Analytics

> Visitors, page views, bounce rate, pages, referrers, countries, devices and custom events per project, without cookies, kept in your own account. Apps using `@vercel/analytics` need no change.

- Category: Monitor
- URL: https://www.forkrail.com/docs/web-analytics

## Turn it on

1. **Switch it on for the project**

   Open the project’s **Analytics** page and choose **Enable**, or use the CLI. It applies within seconds, with no redeploy.

```bash
forkrail project my-site --analytics on      # off stops collecting; what was kept stays
```

2. **Add the script to your pages**

   Add the script tag to your HTML, or keep `@vercel/analytics` if your app already uses it. Then deploy.

```text
<script defer src="/_forkrail/insights/script.js"></script>
```

3. **Open a page**

   Visit your site. The Analytics page shows the view within a few seconds, and who’s online now (visitors in the last 3 minutes).

### Apps that use @vercel/analytics

An app that already has `<Analytics />` from `@vercel/analytics` works as it is: the routers answer its script and beacons themselves, and nothing is sent to Vercel. Custom events with `track()` work too, in the browser and on the server.

```ts
import { track } from '@vercel/analytics'

track('signup', { plan: 'pro' })
```

While analytics is off, the script is an empty one, so you can ship the tag before you turn it on. forkrail’s own package, `@forkrail/analytics`, is in the forkrail source (`packages/analytics`) and isn’t on npm yet; until it is, use the script tag or `@vercel/analytics`.

## Privacy

- **No cookies.** A visitor is a hash of their address, browser and the project under a random salt that changes every UTC day. The same person counts as a new visitor the next day, and neither the address nor the browser string is kept.
- Bots, headless browsers and scripts aren’t counted, nor are beacons from another project’s pages.
- Everything is kept on the analytics server in your AWS account for 13 months.

Because no cookie or personal data is stored on the visitor’s device, many sites can run it without a consent banner. Check what your own rules require.

## Cost and differences from Vercel

Analytics adds no AWS resources: page views go through the routers and into the analytics server you already run. Each beacon counts as a request in the project’s usage, a few hundred bytes of transfer.

|  | forkrail | Vercel |
| --- | --- | --- |
| Price | No charge beyond the beacons’ transfer | Per event, by plan |
| Where data lives | Your AWS account | Vercel |
| Kept | 13 months | By plan |
| Speed Insights | Not collected: its script loads and does nothing | Collected |
