data-* attributes on the script tag. Every option has a sensible default, so the basic snippet works on its own — you only add attributes to change behavior. Configuration is set in the HTML itself, so to change an option you update the snippet and re-deploy.
Which data-* attributes can I set?
Set any of the attributes below on the tracking script tag. Each one has a default, so you only add the ones whose behavior you want to change.
Boolean rule: if an attribute is absent, its default applies. The literal value
"false" turns it off. Any other present value turns it on.Track single-page apps
SPA route tracking is on by default (data-track-spa). When your app changes routes on the client — as React, Vue, Svelte, and similar frameworks do — tinyanalytics records each route change as a new pageview. You don’t need to configure anything for most single-page apps. Set data-track-spa="false" only if you want to record pageviews manually instead.
Why one navigation counts as one pageview
Many SPA routers fire several history events for a single navigation (apushState followed by a replaceState, plus one on hydration). Left unguarded, that inflates pageviews and collapses bounce rate. tinyanalytics prevents it two ways:
- Debounce (
data-debounce, default 500 ms). A burst of route changes within the window collapses into one pageview, sent after the burst so it carries the final URL. Lower it for snappier per-route tracking, or setdata-debounce="0"to fire on every route change immediately. - Same-URL skip. A route change that leaves the URL unchanged records nothing, so a hydration re-render never becomes a phantom second pageview.
Turn auto-capture on or off
tinyanalytics captures outbound links, downloads, button clicks, copies, form submissions, and engagement by default. To disable one, set its attribute to"false":
Collect Core Web Vitals
Web Vitals collection is off by default because it loads a small extra chunk of code only when needed. Turn it on withdata-web-vitals:
Capture JavaScript errors
Error capture is also off by default. Turn it on withdata-track-errors:
error events, grouped by message in the Errors report. Benign ResizeObserver warnings and cross-origin third-party script errors are filtered out automatically. See error tracking for the report and the manual trackError() call.
Hide sensitive paths with skip and mask
If your URLs contain personal or sensitive data — an order number, a token, an email — use path patterns to keep it out of your reports:- Skip drops the event entirely. Use
data-skip-paths. - Mask records the pattern instead of the real path, so the sensitive part never leaves the browser. Use
data-mask-paths.
*matches one path segment ([^/]+).**matches any depth.re:<expression>matches a raw regular expression.
/orders/abc123 is recorded as /orders/*. Masking happens in the browser, so the real path is never sent. A malformed pattern is ignored rather than breaking tracking.
Tag every event on a page
Usedata-tag to stamp a label on every event sent from a page — useful for grouping a campaign, an A/B variant, or a section of your site. The label is truncated to 256 characters.
Opt out of tracking
To exclude yourself (or anyone) from tracking on a device, set adisable-<namespace> key in the browser’s localStorage. With the default namespace, that’s:
Frequently asked questions
How do I turn off a tinyanalytics tracking option?
How do I turn off a tinyanalytics tracking option?
Set the attribute to the literal value
"false" on the tracking script tag — for example, data-track-copy="false". If an attribute is absent its default applies, and any other present value turns it on.Do I have to redeploy my site to change a tracking option?
Do I have to redeploy my site to change a tracking option?
Yes. tinyanalytics configuration lives in the
data-* attributes on the script tag in your HTML, so changing an option means updating the tag and re-deploying your site. Use the snippet builder in Settings → Tracking to generate the updated tag.How do I keep my own visits out of tinyanalytics?
How do I keep my own visits out of tinyanalytics?
Set a
disable-<namespace> key in that browser’s localStorage — with the default namespace, run localStorage.setItem('disable-tinyanalytics', 'true'). While the key is present, the tracking script installs a no-op and sends nothing from that browser.What happens if a path pattern is malformed?
What happens if a path pattern is malformed?
A malformed
data-skip-paths or data-mask-paths pattern is ignored rather than breaking tracking. Valid patterns use * for one path segment, ** for any depth, and re:<expression> for a raw regular expression.Why is my single-page app double-counting pageviews?
Why is my single-page app double-counting pageviews?
Many SPA routers fire more than one history event per navigation, and each could become a pageview. tinyanalytics collapses a burst of route changes into one pageview using a 500 ms debounce (
data-debounce) and skips any route change that doesn’t alter the URL. If a tool navigates by replaceState only and you want a pageview per change, set data-debounce="0".Related
Install the tracking script
Get the snippet and add it to your site.
Track custom events
Send named events with the JavaScript API.
Verify your setup
Confirm your configuration is working.
How tinyanalytics works
What the script sends and what stays in the browser.