Script Configuration
Advanced configuration options for the DataSaaS tracking script, including SPA support, outbound tracking, scroll depth, and more.
Script attributes
| Attribute | Required | Description |
|---|---|---|
| data-website-id | Yes | Your unique website identifier (e.g., mrf_abc123) |
| data-domain | Yes | Your website domain (used to validate events) |
| defer | Recommended | Loads 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:
| Platform | Parameter |
|---|---|
| Google Ads | gclid |
| Facebook / Meta | fbclid |
| Microsoft Ads | msclkid |
| TikTok Ads | ttclid |
| Twitter / X Ads | twclid |
| LinkedIn Ads | li_fat_id |
| Google App Campaigns | gbraid / 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.
The tracking script is ~2KB gzipped with zero external dependencies. It loads asynchronously and won't block your page render.