# Install the website tag

## The snippet

Each property has its own snippet on its **Install** card.
Add it to every page of the site you want counted, in the head or the body:

```html
<script async src="https://konta.la/v1/t.js?k=pk_live_..."></script>
```

- `k` is the property's write key.
Copy the snippet from the Install card so it carries the right one.
- Keep `async`, and never add `type="module"`.
The tag needs to find its own script element.
- There is no inline JavaScript to paste.

On a CMS, a "custom HTML" box takes the line as it is.

## Content Security Policy

If your site sends a Content-Security-Policy, allow `https://konta.la` in both `script-src` and `connect-src`.
Otherwise the browser blocks the tag and the events it sends.
The tag needs nothing else: no `unsafe-inline`, no `unsafe-eval`, and no image or style sources.

Do not add a Subresource Integrity hash to the snippet.
The script carries your property's settings, so its content changes whenever they do.

## Single-page apps

The tag sends a page view for every page opened, including each change of page in a single-page app.
It follows `pushState`, `replaceState`, back and forward, and hash changes, and waits briefly for your router to set the page title.
To count only full page loads, add `data-spa="false"` to the script tag.

## How settings reach your site

Your property's capture settings arrive inside the script itself, so they cost no extra request.
When you change a setting, such as turning on clicks, it reaches your site within a few minutes, with no release on your side.

## Check that it works

Add `data-debug` to the script tag on a test page:

```html
<script async src="https://konta.la/v1/t.js?k=pk_live_..." data-debug></script>
```

The tag then logs every event it captures to the browser console, and warns you about any event it could not send.
Remove it when you are done.

## Size

The tag every visitor downloads is about 15 KB gzipped with page views only.
Each feature you turn on adds its own code, and only properties that use a feature download it.
With everything on, the tag is about 46 KB gzipped.
It runs in Chrome 80, Firefox 74, Safari 13.1 and newer.

## Write keys and rotation

A property can have up to two active write keys, so you can replace a key without losing a single event:

1. Create a new key on the **Write keys** card.
2. Publish the snippet with the new key on every page.
3. Wait for cached copies of your old pages to expire.
Browsers, CDNs and caching plugins can go on serving the old snippet for days.
4. Revoke the old key.

A revoked key cannot be restored, and pages that still carry it stop being counted.

See the [tag reference](/docs/developers/tag-reference) for every option the script tag takes.
