# Script configuration

Every supr-* attribute of the tracking script, the HTML attributes for goals and scroll events, the window.supr() API, and what the script tracks on its own.

The script is configured with `supr-*` attributes on its tag. Only `supr-website-id` is required.

## Script attributes

| Attribute | Default | What it does |
| --- | --- | --- |
| `supr-website-id` | required | Which website the visits belong to (Settings → General). |
| `supr-domain` | the page's host | Sets the visitor cookie on this domain, so all its subdomains share one visitor. See [subdomains](https://supranalytics.app/docs/subdomain-tracking.md). |
| `supr-allowed-hostnames` | none | Your other domains, comma-separated. Links to them keep the same visitor. See [cross-domain tracking](https://supranalytics.app/docs/cross-domain-tracking.md). |
| `supr-api` | \<script origin>/api/event | Where events are sent: a full URL or a path on your site. See [your own proxy](https://supranalytics.app/docs/own-proxy.md). |
| `supr-allow-localhost` | false | `true` tracks `localhost`, `127.0.0.1` and `.local` hosts, which are ignored otherwise (unless Track localhost is on in Settings → General). |
| `supr-hash` | false | `true` counts `#/route` changes as pages. See [hashed paths](https://supranalytics.app/docs/hashed-page-paths.md). |
| `supr-cookieless` | false | `true` sets no cookies at all. See [cookieless tracking](https://supranalytics.app/docs/cookieless-tracking.md). |
| `supr-outbound` | true | `false` stops tracking clicks on links to other websites. |
| `supr-polar` | true | `false` stops adding `reference_id` to [Polar checkout links](https://supranalytics.app/docs/polar-checkout-links.md). |
| `supr-dodo` | true | `false` stops adding the visitor id to [Dodo Payments payment links](https://supranalytics.app/docs/dodo.md). |
| `supr-paddle` | true | `false` stops adding the visitor id to [Paddle checkout buttons](https://supranalytics.app/docs/paddle.md). |

## HTML element attributes

| Attribute | What it does |
| --- | --- |
| `supr-goal` | A click on the element completes this goal. See [custom goals](https://supranalytics.app/docs/custom-goals.md). |
| `supr-goal-*` | Properties of that goal: `supr-goal-plan="pro"` sends `plan: "pro"`. |
| `supr-scroll` | The goal is completed when the element scrolls into view. See [scroll events](https://supranalytics.app/docs/scroll-tracking.md). |
| `supr-scroll-threshold` | How much of the element must be visible, 0 to 1 (default 0.5). |
| `supr-scroll-delay` | How long it must stay visible first, in milliseconds. |
| `supr-scroll-*` | Properties of that goal. |
| `supr-mask` | Hides the element's text in [session recordings](https://supranalytics.app/docs/session-recordings.md) and heatmap snapshots. |
| `supr-block` | Leaves the element out of session recordings and heatmap snapshots entirely. |

## JavaScript API

| Call | What it does |
| --- | --- |
| `supr("goal_name", props?)` | Completes a goal, with up to 10 properties. |
| `supr("identify", { user_id, email, name })` | Names the visitor. See [user identification](https://supranalytics.app/docs/user-identification.md). |
| `supr("pageview")` | Sends a pageview now (for routers the script can't see). |
| `supr.visitorId()` | The visitor's id, for [revenue attribution](https://supranalytics.app/docs/revenue-attribution.md). |
| `supr.sessionId()` | The current visit's id. |

Installed with older names? They keep working: the `data-` versions of every attribute above (`data-website-id`, `data-domain`, `data-supr-goal`, `data-supr-scroll`, `data-supr-mask` and the rest; when a tag has both, the `supr-` one wins).

## What the script tracks on its own

- A pageview on load, and on every `history.pushState`, `replaceState` and back/forward navigation.
- Clicks on links to other websites (the Exit link report), unless `supr-outbound="false"`.
- A heartbeat every 30 seconds while the tab is visible and in use, for session time and the live view, and a goodbye when the page closes.
- With [session recordings](https://supranalytics.app/docs/session-recordings.md) or [heatmaps](https://supranalytics.app/docs/heatmaps.md) turned on for the website, it loads a second script, `/js/recorder.js`, from SuprAnalytics on the pages there is something to capture. There's nothing to add to the snippet.

## Examples

Production:

```
<script defer supr-website-id="YOUR_WEBSITE_ID" supr-domain="yourdomain.com" src="https://supranalytics.app/js/script.js"></script>
```

Development:

```
<script defer supr-website-id="YOUR_WEBSITE_ID" supr-allow-localhost="true" src="https://supranalytics.app/js/script.js"></script>
```

Cookieless:

```
<script defer supr-website-id="YOUR_WEBSITE_ID" supr-cookieless="true" src="https://supranalytics.app/js/script.js"></script>
```

Hash router:

```
<script defer supr-website-id="YOUR_WEBSITE_ID" supr-hash="true" src="https://supranalytics.app/js/script.js"></script>
```

Own proxy:

```
<script defer supr-website-id="YOUR_WEBSITE_ID" supr-domain="yourdomain.com" src="/js/script.js" supr-api="/api/event"></script>
```

---

This page on the web: https://supranalytics.app/docs/script-configuration
Every documentation page: https://supranalytics.app/docs.md
