Skip to main content
You configure the tinyanalytics tracking script with 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.
You don’t have to write these by hand. In Settings → Tracking, the snippet builder lets you toggle options and copies the updated tag for you. Only non-default options are added, so your snippet stays as short as possible.

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 (a pushState 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 set data-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.
A debounced pageview can be missed if the tab closes inside the window; the initial page-load pageview is never debounced.

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":
Form capture records only the shape of a submission — the form’s name, action, and field count. It never captures what a visitor typed, and it skips hidden, password, disabled, and read-only fields.

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 with data-web-vitals:
tinyanalytics then sends one performance event per page load with LCP, CLS, INP, FCP, and TTFB, which power the Performance report.

Capture JavaScript errors

Error capture is also off by default. Turn it on with data-track-errors:
tinyanalytics then records uncaught exceptions and unhandled promise rejections as 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.
Patterns use this syntax:
  • * matches one path segment ([^/]+).
  • ** matches any depth.
  • re:<expression> matches a raw regular expression.
With this, a visit to /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

Use data-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 a disable-<namespace> key in the browser’s localStorage. With the default namespace, that’s:
While that key is present, the script installs a no-op and sends nothing from that browser. This is the recommended way to keep your own visits out of your stats.

Frequently asked questions

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.
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.
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.
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.
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".

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.