# Script tag

Paste one line into your page head. The script is under 1 KB gzipped, loads with defer and works on any site.

The script tag works on any site: plain HTML, a server-rendered app or a site builder. It is under 1 KB gzipped and loads with `defer`, so it never blocks your page.

## Add the snippet

Paste it once, into the `<head>` of your site's main layout or base template. [Other frameworks](/docs/install/frameworks) names that file in SvelteKit, Nuxt, Astro, Laravel and others.

```html
<script defer src="https://cdn.ultanimus.com/s.js" data-site="YOUR_SITE_ID"></script>
```

| Attribute | What it does |
|---|---|
| `defer` | Loads the script after the page is parsed, so rendering never waits for it. |
| `src` | The script itself. |
| `data-site` | Your site ID. The install page fills it in, and the site's settings show it. |
| `data-outbound` | Optional. Records clicks on links to other sites. See [Links and downloads](/docs/tracking/links-and-downloads). |
| `data-downloads` | Optional. Records clicks on links to files, such as a PDF or an installer. |
| `data-user` | Optional. Your own ID for the signed-in person, so they count as one visitor across days. See [Signed-in users](/docs/tracking/identify). |
| `data-load` | Optional. Measures what one page load in ten downloads, or the share you set from 1 to 100, for the [Load page](/docs/dashboard/load). |
| `data-vitals` | Optional. Measures LCP, INP, CLS, FCP and TTFB on every page load, or the share you set from 1 to 100, for the [Web vitals page](/docs/dashboard/vitals). |
| `data-errors` | Optional. Reports the JavaScript errors visitors run into, with the stack and the page, for the [Errors page](/docs/dashboard/errors). The code that reads them loads only when a page throws. |

## One copy per page

Add the snippet once, in the shared layout. If a page loads it twice, for example the snippet and the Next.js component together, the second copy counts nothing, and your site's settings show a note until you remove it.

## What it sends

After the page loads, the script sends one pageview with `sendBeacon`, which arrives even when the visitor leaves right away.

A pageview carries the page address, the referrer, the screen size and the browser language, and the user ID if you pass one. No cookies are read or written. [Privacy and data](/docs/platform/privacy) has the full list.

## Content Security Policy

If your site sends a `Content-Security-Policy` header or meta tag, the browser blocks the script until the policy allows it. No event arrives and the install check keeps waiting. Add the tracker's domain to two directives:

```text
script-src 'self' https://cdn.ultanimus.com
connect-src 'self' https://cdn.ultanimus.com
```

`script-src` lets the browser load the script, and `connect-src` lets it send events. Add the domain next to the sources you already list and leave the rest of the policy as it is. A policy without these two directives uses `default-src` for both, so add the domain there instead.

In Next.js the policy usually lives in `headers()` in `next.config` or in the proxy file. On other sites, look in the server or hosting config, or a `<meta http-equiv="Content-Security-Policy">` tag.

## Check that it works

Open a page with the script, then your dashboard. The install check turns live when the first event arrives. If it does not:

- Check that `data-site` matches your site ID.
- Check that the page is on the domain you added or one of its subdomains. Events from anywhere else do not count.
- Open the browser console. A "Refused to load the script" or "Refused to connect" error means a [Content Security Policy](#content-security-policy) blocks the tracker.
- Look for the script in your browser's network tab. Some ad blockers stop analytics scripts; proxy snippets help, and [Pricing](/pricing) shows which plans include them.
