Exclude pages and mask URLs in the tracker
Exclude pages and mask URLs in the browser: control which hostnames and paths are tracked and which URL is recorded, including query parameters.
Everything on this page happens in the browser, before anything is sent. The server applies its own rules afterwards (site domains, traffic rules, path masks, the allowed query parameters and the PII scrubber).
Only some hostnames: data-domains#
data-domains="example.com,www.example.com"
Nothing is sent on any other hostname: staging servers, preview deployments, translation proxies, copies of your site. The match is exact, so list each hostname you use.
The server also drops hits whose hostname isn't one of the site's domains
(or a subdomain of one), so data-domains is mostly useful when your
staging hosts are subdomains of your main domain.
Skip paths: data-exclude#
data-exclude="/admin/*,/preview/*,/account/*"
Comma-separated globs matched against the path (no query string). *
matches any characters, including /, so /admin/* excludes everything
under /admin/. /admin itself needs its own entry.
Excluded pages send nothing at all: no pageview, events, engagement, Web
Vitals or clicks. With data-canonical="true" the globs are matched
against the canonical URL's path.
Rewrite paths: data-mask#
Group URLs that contain ids into one page, and keep ids out of your data:
data-mask="/users/*/settings->/users/:id/settings,/orders/*->/orders/:id"
Each rule is glob->replacement. The first matching rule replaces the
whole path. * matches any characters, including /. Exclusions are
checked before masks, against the original path.
Prefer server-side path masking (Site settings → Privacy) when you
can (Path masks): it applies to every hit, whatever the snippet on
the page says, and its * matches exactly one path segment. Client-side
masks are useful when the id itself must never leave the browser.
Keep query parameters: data-params#
By default the tracker keeps only campaign parameters (utm_*, ref,
via, source) and click ids (the full list is in
Script attributes),
and drops everything else before sending.
data-params="page,category"
keeps page and category too. The server stores a query parameter only
if it's also in the site's Allowed query parameters (Site settings →
Privacy), so add it there as well. Parameters are then part of the page
path in reports, sorted by name: /search?category=shoes.
Canonical URLs: data-canonical#
data-canonical="true"
Reports the href of <link rel="canonical"> instead of the address bar
URL. A page without a canonical link reports its own URL. Useful when the same content lives under several URLs (tracking
parameters, print views, pagination). Campaign parameters from the address
bar are lost when the canonical URL doesn't carry them.
Hash routing: data-hash#
data-hash="true"
Keeps every #fragment in the path (/#/settings, and also plain anchors
such as /docs#install), and sends a pageview when the fragment changes
(unless data-spa="off"). data-spa="hash" turns it on too.
Without it, the default data-spa="auto" keeps only route-like fragments
(those starting with #/ or #!/) and drops plain anchors. With
data-spa="history" or data-spa="off" the fragment is always dropped.
See Single-page apps.