Installation
Add the configuration and script to your HTML:Configuration
Setwindow.StaminadsConfig before loading the SDK:
Configuration Options
Cross-Domain Tracking
By default, sessions are isolated per domain. When a visitor navigates fromblog.example.com to shop.example.com, the SDK would create a new session on the shop domain — losing the connection to the original visit.
Cross-domain tracking solves this by sharing session identity across domains, so you get:
- Accurate session counts — One visitor journey = one session, not multiple
- Complete user paths — See the full journey from blog article to checkout
- Correct attribution — UTM parameters and referrer data stay with the session
How It Works
- When a user clicks a link to a configured domain, the SDK appends a
_stmparameter with encrypted session data - On the target domain, the SDK reads the parameter and continues the same session
- The parameter is stripped from the URL automatically (if
crossDomainStripParams: true)
Manual URL Decoration
For programmatic navigation, usedecorateUrl():
Cross-domain linking only works for domains in the
crossDomains array. Links to other domains are not decorated.API Reference
Session Information
Page Views
Page views are tracked automatically, but you can trigger them manually for SPAs:Goals
Track conversions and goals with optional value:Custom Dimensions
Set custom dimensions (1-10) for advanced segmentation. There are two ways to set dimensions:Via URL Parameters (Automatic)
Custom dimensions can be set via URL parametersstm_1 through stm_10. They are automatically captured when the SDK initializes:
- Campaign tracking links
- A/B test variant assignment
- Affiliate tracking
- Any scenario where you want to pass dimension values via URL
Priority rule: Existing dimension values take priority over URL parameters. If a dimension is already set (e.g., from a previous page in the session), the URL parameter will NOT overwrite it.
Via JavaScript (Programmatic)
User Identification
Associate sessions with authenticated users for cross-device tracking and user-level analytics:Control Methods
Debugging
Automatic Tracking
The SDK automatically tracks the following without any code:UTM Parameters
UTM parameters are automatically captured from URLs:Ad Click IDs
The SDK automatically detects and captures ad network click IDs:Focus State Tracking
The SDK tracks engagement using a focus state machine:
Only FOCUSED time counts toward engagement duration, giving you accurate TimeScore calculations.
Offline Support
Events are queued when offline and sent when connectivity returns:- Queue holds up to 50 events
- Events expire after 24 hours
- Uses Beacon API with Fetch fallback
- Handles Safari Private Mode gracefully
Privacy & Compliance
- No cookies — Uses localStorage with memory fallback
- No PII — Does not collect personal identifiable information
- Bot filtering — Automatically excludes crawlers and bots