Source: https://usedataowl.com/docs/script-configuration
Markdown source: https://usedataowl.com/docs/script-configuration.md
Description: Complete technical reference for the <4KB DataOwl tracking script, data-* configuration attributes, and the window.datasense JavaScript API.

# Tracking Script Configuration & JavaScript SDK Reference

The script is one file under 4 KB, plain ES5, with no dependencies. Load it with `defer` so it never blocks rendering.

## Builds

| Script | Visitor recognition |
| --- | --- |
| `/js/script.cookies.js` | First-party `datasense_vid` (400 days) and `datasense_sid` (30-minute session) cookies. The default for new sites. |
| `/js/script.js` | Nothing stored on the device. See [cookieless tracking](/docs/gdpr-cookieless-tracking). |

## Attributes

| Attribute | Default | What it does |
| --- | --- | --- |
| `data-website-id` | required | Your site ID from the dashboard. |
| `data-api` | next to the script | Where events go. Defaults to `/api/e` beside the script, which is what makes the [proxy](/docs/proxy-guide) work with no config. `data-api-url` works too. |
| `data-allowed-hostnames` | none | Comma-separated other domains of yours. Links to them carry the visitor along: see [cross-domain tracking](/docs/cross-domain-tracking). |
| `data-disable-payments` | `false` | Set to `true` to stop reading payment link success URLs (`session_id`, `checkout_id`, `payment_id`). See [duplicate payments](/docs/fix-duplicate-payments). |
| `data-allow-localhost` | `false` | Set to `true` to record visits on localhost while you test. |
| `data-track-errors` | `true` | Set to `false` to turn off [error tracking](/docs/error-tracking). |
| `data-respect-dnt` | `false` | Set to `true` to ignore browsers that send Do Not Track. |
| `data-replay` | `false` | Set to `true` to load the [session recorder](/docs/session-replay). |
| `data-replay-api` | next to the script | Where replay chunks go, if not `/api/replay` beside the script. |
| `data-forms` | `true` | Set to `false` to never load [forms](/docs/forms-setup). |

## JavaScript API

| Call | What it does |
| --- | --- |
| `datasense("signup", { plan: "pro" })` | Records a [custom goal](/docs/custom-goals). |
| `datasense("identify", userId, traits)` | Ties the visitor to your user. See [user identification](/docs/user-identification). |
| `datasense("reset")` | Starts a new visitor and session (cookie script). Call it on sign-out. |
| `datasense("payment", { email })` | Credits the payment with that customer email to this visit. See [revenue attribution](/docs/revenue-attribution-guide). |
| `datasense.sessionId()` | The current session ID, for [revenue attribution](/docs/revenue-attribution-guide). |
| `datasense.visitorId()` | The visitor ID (cookie script only; `null` on the cookieless one). |
| `datasense("showForm", formId, { force })` | Opens a live [form](/docs/forms-setup#open-a-form-from-your-code) now. `datasense.showForm(formId)` works too. |

Calls made before the script has loaded are kept by this stub, placed above the script tag, and run once it loads:

```html
<script>
  window.datasense = window.datasense || function () {
    (window.datasense.q = window.datasense.q || []).push(arguments)
  }
</script>
```
)}

## Single-page apps

`history.pushState`, `history.replaceState` and the back button count as pageviews, once per URL. When the visitor moves on or hides the tab, the script reports the visible time they spent on the page, capped at 30 minutes.

## What the script ignores

- `localhost`, `127.*`, `[::1]`, `0.0.0.0` and `file:` pages, unless `data-allow-localhost="true"`.
- Automated browsers: WebDriver, Cypress, PhantomJS and Nightmare.
- [Excluded visits](/docs/excluding-analytics).
