Tracking script reference
Updated
Load script.js with data-site-id and data-domain; everything else is optional. Call window.datapocket(name, props) for goals: names and property keys are lowercase [a-z0-9_-], at most 10 properties, values cut to 255 characters. For a script that never changes, load a pinned version such as [email protected] with its published integrity hash.
Script files
| File | Use it when |
|---|---|
script.js | The default. A first-party cookie (dp_vid) recognizes returning visitors for a year, which gives the most accurate attribution. |
script.hash.js | Your app routes with the URL hash (/#/settings): hash changes count as pageviews and the hash is part of the path. |
script.cookieless.js | You can't set cookies. See cookieless mode for what you give up. |
[email protected] (and script.hash@…, script.cookieless@…) | You want a file that never changes, to pin with Subresource Integrity. See pinned versions. |
All of them are served from https://datapocket.vo1d.studio/js/, or from your own domain through a first-party proxy.
Bot traffic
DataPocket drops automated traffic before it reaches your numbers and counts what it dropped, so the Bots card shows "Filtered bot traffic" with the reason for each hit:
| Reason | What it catches |
|---|---|
| Crawlers and tools | Known bot user agents, and headless or automated browsers (Puppeteer, Playwright, Selenium, navigator.webdriver). |
| Data centers | Visitors whose network is a cloud or hosting provider (AWS, Google Cloud, Azure, Hetzner, OVH, DigitalOcean…). iCloud Private Relay, Cloudflare WARP and corporate security gateways such as Zscaler are never treated as data centers. |
| Scripts | Requests sent straight to DataPocket without the headers every browser adds (Sec-Fetch-* and Accept-Language). |
| Bursts | One address and browser starting many new visitors for your site within minutes, a bot that clears its cookies on every page. |
| Prerendering | Pages the browser loaded in advance but never showed. From script 1.0.2 a prerendered page counts when it's shown. |
If your visitors reach your site through a VPN that runs on a cloud provider, turn off the data-center filter under Settings → Tracking.
Crawlers that never run the script, such as GPTBot, ClaudeBot and PerplexityBot, are counted separately when your server reports them: see AI crawler tracking.
Attributes
| Attribute | What it does |
|---|---|
data-site-id | Required. Your site's public id, from its Install page. |
data-domain | Required. Your domain without www.. Cookies are set on it, so subdomains share one visitor. |
data-allowed-hostnames | Other domains you own, comma-separated. Links to them carry the visitor along, so a journey across domains stays one visitor (not in cookieless mode). |
data-exclude | Paths where nothing is sent, comma-separated. See excluding pages. |
data-query-params | Query parameters to send besides the defaults, comma-separated (page,plan), or * for all of them. See what leaves the browser. |
data-api | Send events to this URL instead of next to the script. Useful when your proxy serves the script and the event endpoint from different paths. |
data-disable-vitals="true" | Don't measure Core Web Vitals. |
data-disable-payments="true" | Don't read checkout return parameters (session_id, checkout_id, order_id) from the URL. |
data-debug="true" | Log every event to the console, and track inside iframes (skipped otherwise). |
data-allow-localhost="true" | Track on localhost and *.local (skipped otherwise). |
data-allow-file-protocol="true" | Track pages opened from file://. |
To stop tracking your own visits in one browser, run localStorage.setItem("dp_ignore", "true") in its console.
JavaScript API
window.datapocket(name, properties)
window.datapocket("signup", { plan: "pro", source: "onboarding" })name: the goal. It's lowercased, spaces become_, characters other thana-z 0-9 _ - :are removed and it's cut to 64 characters.paymentandidentifyare reserved (below).properties: optional. Keys are lowercased and must match[a-z0-9_-]{1,64}; at most 10; values are turned into strings and cut to 255 characters.- An invalid key or an 11th property drops the whole call, with a warning in the console and nothing sent.
window.datapocket.versionis the script's version.window.datapocket.visitorIdis set in cookieless mode once the first event has been answered.
Goals without JavaScript: data-dp-goal="signup" on any element counts a click, with data-dp-goal-<key>="value" attributes as properties; data-dp-scroll="pricing_seen" counts when the element scrolls into view (data-dp-scroll-threshold, 0 to 1, default 0.5; data-dp-scroll-delay in milliseconds).
Calling it before the script loads
The script loads with defer, so an inline script or your app's entry may run first. Define this queue before your first call; the script sends everything queued as soon as it runs:
<script>
window.datapocket = window.datapocket || function () {
(window.datapocket.q = window.datapocket.q || []).push(arguments);
};
</script>Identify and payment
datapocket("identify", { user_id: "u_123", name: "Ada", email: "[email protected]" })links the visitor to your user, so payments your server reports by email or customer id find their visitor.user_idis required;name,emailandimageare optional. Not available in cookieless mode.datapocket("payment", { transaction_id: "order_123" })links this visitor to the payment your server reports to the Payment API with the sametransaction_id, in either order, within a day. Only the id is sent: no email, no amount. Anyone could send a call for an id they guess, so it's used only when one visitor alone sent it; passingvisitor_idfrom your server is more reliable. (Older versions took anemail; it's now ignored with a console warning.)
What leaves the browser
Each event carries the page URL, the referrer, the screen size, the browser's language and time zone, and the visitor and session ids. Query strings often carry secrets (password-reset and magic-link tokens, signed URLs), so the script trims what it sends:
- Page URL: only
utm_*,ref,source,viaand ad click ids (gclid,gbraid,wbraid,fbclid,msclkid,ttclid,twclid,li_fat_id) are kept from the query. Add others withdata-query-params="page,plan", or send the whole query withdata-query-params="*". The hash is sent only for hash routes (#/path), without its own query. - Referrer and outbound links: origin and path only.
- The server applies its own filter too: parameters named like secrets (
token,code,key,signature,password,redirect, pre-signedX-Amz-*andX-Goog-*…) are never stored, even with*. - Cookies set by
script.js:dp_vid(visitor, 1 year),dp_vfs(first visit, 1 year),dp_vsn(visit count, 1 year),dp_sid(session, 30 minutes, renewed on activity). First-party,SameSite=Lax, readable by your own code so you can passdp_vidto your checkout.
Excluding pages
data-exclude takes a comma-separated list, checked before every event, so single-page app navigation is covered:
| Pattern | Matches | Doesn't match |
|---|---|---|
/account | /account only | /account/billing, /accounts |
/account/* | /account/billing, /account/a/b | /account, /accounts |
/account* | /account, /account/billing, /accounts | /my/account |
Your dashboard's excluded paths (Settings → Tracking) use the same syntax and are applied on the server, so they also cover events sent by older copies of your page.
Pinned versions
script.js is updated in place. Each release is also published as a file that never changes, /js/script@<version>.js, so you can pin it with Subresource Integrity. The browser then refuses to run the file if a single byte differs. Every release and its hash: https://datapocket.vo1d.studio/js/sri.json.
<script
defer
src="https://datapocket.vo1d.studio/js/[email protected]"
integrity="sha384-MsNyCZ/DPx8RAIgpvlbt3Xu5P4nLTNb3fkJL3M1m11GcXaefXQiun6R/11wdkd+N"
crossorigin="anonymous"
data-site-id="YOUR_SITE_ID"
data-domain="YOUR_DOMAIN"
></script>| File | integrity |
|---|---|
[email protected] | sha384-MsNyCZ/DPx8RAIgpvlbt3Xu5P4nLTNb3fkJL3M1m11GcXaefXQiun6R/11wdkd+N |
[email protected] | sha384-klopDNmlO9zk9bfLkbcNq5leZVlLH85RuKf0xxb5e7WvAp+ikX3OV/yX0PRJcWqr |
[email protected] | sha384-BCzLRGOeV+R7R7fespWD7sa9bfwS8W/5U2kwcXSwixWs1DGd444i9Img/ls4YXOQ |
A pinned file doesn't get fixes; check sri.json for newer versions now and then. Behind a first-party proxy, use the same file name through your proxy (/dp/js/[email protected]): the hash stays the same.
Questions
- Can I use the script with a Content Security Policy?
- Yes. Allow the script's origin (or your own, when proxied) in
script-srcand the event endpoint inconnect-src. With a pinned version you can also require itsintegrityhash. - Is there an npm package?
- Not on the npm registry yet. Use the script tag, and the REST API from your server.