Advanced features

Script configuration

Every supr-* attribute of the tracking script, the HTML attributes for goals and scroll events, the window.supr() API, and what the script tracks on its own.

The script is configured with supr-* attributes on its tag. Only supr-website-id is required.

Script attributes

AttributeDefaultWhat it does
supr-website-idrequiredWhich website the visits belong to (Settings → General).
supr-domainthe page's hostSets the visitor cookie on this domain, so all its subdomains share one visitor. See subdomains.
supr-allowed-hostnamesnoneYour other domains, comma-separated. Links to them keep the same visitor. See cross-domain tracking.
supr-api<script origin>/api/eventWhere events are sent: a full URL or a path on your site. See your own proxy.
supr-allow-localhostfalsetrue tracks localhost, 127.0.0.1 and .local hosts, which are ignored otherwise (unless Track localhost is on in Settings → General).
supr-hashfalsetrue counts #/route changes as pages. See hashed paths.
supr-cookielessfalsetrue sets no cookies at all. See cookieless tracking.
supr-outboundtruefalse stops tracking clicks on links to other websites.
supr-polartruefalse stops adding reference_id to Polar checkout links.
supr-dodotruefalse stops adding the visitor id to Dodo Payments payment links.
supr-paddletruefalse stops adding the visitor id to Paddle checkout buttons.

HTML element attributes

AttributeWhat it does
supr-goalA click on the element completes this goal. See custom goals.
supr-goal-*Properties of that goal: supr-goal-plan="pro" sends plan: "pro".
supr-scrollThe goal is completed when the element scrolls into view. See scroll events.
supr-scroll-thresholdHow much of the element must be visible, 0 to 1 (default 0.5).
supr-scroll-delayHow long it must stay visible first, in milliseconds.
supr-scroll-*Properties of that goal.
supr-maskHides the element's text in session recordings and heatmap snapshots.
supr-blockLeaves the element out of session recordings and heatmap snapshots entirely.

JavaScript API

CallWhat it does
supr("goal_name", props?)Completes a goal, with up to 10 properties.
supr("identify", { user_id, email, name })Names the visitor. See user identification.
supr("pageview")Sends a pageview now (for routers the script can't see).
supr.visitorId()The visitor's id, for revenue attribution.
supr.sessionId()The current visit's id.

Installed with older names? They keep working: the data- versions of every attribute above (data-website-id, data-domain, data-supr-goal, data-supr-scroll, data-supr-mask and the rest; when a tag has both, the supr- one wins).

What the script tracks on its own

  • A pageview on load, and on every history.pushState, replaceState and back/forward navigation.
  • Clicks on links to other websites (the Exit link report), unless supr-outbound="false".
  • A heartbeat every 30 seconds while the tab is visible and in use, for session time and the live view, and a goodbye when the page closes.
  • With session recordings or heatmaps turned on for the website, it loads a second script, /js/recorder.js, from SuprAnalytics on the pages there is something to capture. There's nothing to add to the snippet.

Examples

<script defer supr-website-id="YOUR_WEBSITE_ID" supr-domain="yourdomain.com" src="https://supranalytics.app/js/script.js"></script>

AI agent or LLM? Read this page as Markdown