Script Configuration

Advanced configuration options for the DataSaaS tracking script, including SPA support, outbound tracking, scroll depth, and more.

Script attributes

AttributeRequiredDescription
data-website-idYesYour unique website identifier (e.g., mrf_abc123)
data-domainYesYour website domain (used to validate events)
deferRecommendedLoads the script without blocking page render

Domain validation

The data-domainattribute must match the actual hostname of the page. If there's a mismatch, events are silently dropped. This prevents unauthorized sites from sending events to your dashboard.

SPA support

DataSaaS automatically tracks navigation in Single Page Applications. No extra setup needed.

The tracking script intercepts the browser's History API:

  • pushState — Fires a new pageview when your app navigates
  • popstate — Tracks back/forward browser navigation
  • hashchange — Tracks hash-based routing (e.g., #/about)

Works automatically with:

  • Next.js (App Router and Pages Router)
  • React Router
  • Vue Router
  • SvelteKit
  • Any framework using the History API

Outbound link tracking

DataSaaS automatically detects and tracks clicks on links that point to external domains. When a visitor clicks a link where the hostname differs from the current page, an _outbound event fires with the destination URL.

View outbound data in:

  • Pages card → Exit Links tab — Which external URLs visitors click most
  • Engagement card → _outbound goal — Conversion rate and total clicks

Scroll depth tracking

DataSaaS captures scroll depth when a visitor leaves a page. When the visitor navigates away or closes the tab, a _leave event fires that includes:

  • Scroll depth — Percentage of the page scrolled (0–100%)
  • Duration — Time spent on the page in seconds

This uses the Beacon API for reliable delivery, even when the browser tab is closing.

Ad click ID tracking

Click IDs from major ad platforms are captured automatically from the URL:

PlatformParameter
Google Adsgclid
Facebook / Metafbclid
Microsoft Adsmsclkid
TikTok Adsttclid
Twitter / X Adstwclid
LinkedIn Adsli_fat_id
Google App Campaignsgbraid / wbraid

Bot filtering

The tracking script automatically skips:

  • navigator.webdriver (headless browsers)
  • __nightmare (Nightmare.js)
  • _phantom / callPhantom (PhantomJS)

Server-side bot filtering is also applied based on User-Agent patterns.

Do Not Track

DataSaaS respects the browser's Do Not Track (DNT) setting. When DNT is enabled, no events are sent.

Note

The tracking script is ~2KB gzipped with zero external dependencies. It loads asynchronously and won't block your page render.