# Tracker JavaScript API
> Every option and command the Supametrics tracking script supports, with copy-paste examples.
Source: https://supametrics.io/docs/tracker-javascript-api
The tracking script (`ax.js`) records pageviews on its own. This page lists everything else it can do: the
attributes you can put on the script tag, and the commands your own code can send through
`window.analyticsx`. For a first install, start with [Install and verify the script](https://supametrics.io/docs/install-the-script).
## The script tag
```html
```
Copy the exact snippet, with your site ID filled in, from **Site settings › General** (or the **Setup**
screen before your site is verified). Put it inside `
` on every page.
Without `data-site` the script does nothing.
## Script tag attributes
| Attribute | Default | What it does |
|---|---|---|
| `data-site="..."` | required | Your website's public site ID. |
| `data-consent="required"` | off | Sends nothing and sets no cookies until your code calls `analyticsx('consent', true)`. See [Consent](#consent). |
| `data-domain="example.com"` | detected | The domain the visitor cookies are set on. By default the script picks your root domain, so `example.com` and `app.example.com` share one visitor. Set this only if detection picks the wrong one. |
| `data-api="https://..."` | `https://app.supametrics.io/api/event` | Where events are sent. Use it when you proxy tracking through your own domain. |
| `data-allow-localhost` | off | Also track on local development hosts (see [Local development](#local-development)). |
> **Note:** When the `data-api` address ends in `/event`, the script also loads its click-goal settings
> through your proxy, from the same address with `/event` replaced by `/config/`; forward that
> `GET` to `https://app.supametrics.io/api/config/`. If the proxy doesn't answer it, or the address
> ends differently, the settings load from the address the script came from (`
```
Those visits are stored under their hostname (for example `localhost`). Remove the attribute before you
deploy, or drop that hostname later in **Site settings › Exclusions**.
The script also does nothing in automated browsers (when `navigator.webdriver` is set), so end-to-end test
runs are not counted.
## When the script is blocked
If an ad blocker blocks the script, or it fails to load, `window.analyticsx` is never defined. Calls written
as `window.analyticsx?.(...)` then do nothing and your page keeps working. Calls written as
`window.analyticsx(...)` throw an error.
If your code may run before the script has loaded (the script uses `defer`), you can add a small queue in
front of the snippet. Calls made before the script loads are kept and run once it starts:
```html
```
With the queue in place, `track`, `identify`, `pageview` and `consent` calls are replayed in order.
`visitorId` cannot return a value from the queue; call it after the page has loaded.
> **Note:** with the queue, `window.analyticsx` always exists, so if the script is blocked your queued calls
> simply never send.
## What the script sends
- Personal parameters in the page address (`email`, `e-mail`, `name`, `phone`, `password`, `pass`,
`token`, `access_token`, `id_token`, `auth`, `code`, `secret`, `key`, `api_key`, `license_key`,
`license`, in any letter case) are removed in the browser before anything is sent.
- Each event has its own ID, so a request the browser retries is stored once.
- Page addresses longer than 2,000 characters are rejected by the server, and so is any request over 8 KB.
- Requests use `text/plain` and send no cookies to Supametrics, so there is no CORS preflight.
- Bots are ignored on the server (see [Bots and AI crawlers](https://supametrics.io/docs/bot-tracking)).
Cookies and storage the script uses, all on your own domain:
| Name | Where | Lifetime | Purpose |
|---|---|---|---|
| `ax_vid` | cookie | 1 year | Visitor ID |
| `ax_sid` | cookie | 30 minutes, renewed on each event | Visit (session) ID |
| `ax_ignore` | localStorage | until removed | Set by `?ax_ignore=true` |
| `ax_consent` | localStorage | until withdrawn | Consent given |
| `ax_goals_` | sessionStorage | 1 minute | Cached click goals |
For what is collected and why, see [What Supametrics collects](https://supametrics.io/docs/how-tracking-works).
## Moving from DataFast
`window.datafast` takes DataFast's call style, so goal code written for DataFast keeps working:
- `datafast('signup')` tracks the event `signup`, like `analyticsx('track', 'signup')`.
- `datafast('identify', { user_id, email, name })` identifies the visitor, like `analyticsx('identify', { id, email, name })`.
Calls queued before the script loaded are sent once it has. To bring your DataFast history too, see
[Import from DataFast](https://supametrics.io/docs/import-from-datafast).
## Installed as DataFaster
Supametrics used to be called DataFaster. Sites installed before the rename keep working unchanged:
- `/js/df.js` serves the same script as `/js/ax.js`.
- `window.datafaster` is the same function as `window.analyticsx`, with the same commands.
- `?df_ignore=true` still excludes a browser, like `?ax_ignore=true`.
- Old `df_vid` and `df_sid` cookies (and saved `df_` settings) are moved to the `ax_` names on the first
visit, so returning visitors keep their ID.
Switch to the `ax.js` snippet and `window.analyticsx` whenever convenient.
---
This is one page of the Supametrics help center (section: Developers).
- Index of every page: https://supametrics.io/llms.txt
- Every page in one file: https://supametrics.io/llms-full.txt