RUM Script Installation
Complete guide to installing and configuring the VitalSentinel Real User Monitoring script.
The VitalSentinel RUM (Real User Monitoring) script collects Core Web Vitals and performance metrics from your actual visitors. It's lightweight (~11KB gzipped) and non-blocking.
Basic Installation
Add this script to the <head> section of your HTML:
<script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
async
></script>Find your tracking ID in Domain Settings → Real User Monitoring (RUM).
Configuration Options
Customize the script behavior using data-* attributes:
| Attribute | Type | Default | Description |
|---|---|---|---|
data-key | string | required | Your unique tracking ID |
data-sample-rate | number | 1.0 | Sampling rate (0.0-1.0) |
data-debug | boolean | false | Enable console logging |
data-engagement | boolean | true | Track scroll/time on page |
data-mask-text | boolean | false | Redact text content |
data-mask-selectors | boolean | false | Redact CSS selectors |
data-filter-query-params | boolean | false | Remove query parameters |
Example with Options
<script
src="https://rum.vitalsentinel.com/rum.js"
data-key="abc123"
data-sample-rate="0.5"
data-debug="true"
data-engagement="true"
async
></script>What Data is Collected
Core Web Vitals
The script automatically tracks all Core Web Vitals:
- LCP (Largest Contentful Paint) - Loading performance
- FCP (First Contentful Paint) - Initial render time
- CLS (Cumulative Layout Shift) - Visual stability
- INP (Interaction to Next Paint) - Interactivity
- TTFB (Time to First Byte) - Server response time
Navigation Timing
- DNS lookup time
- TCP connection time
- Request/response time
- DOM load time
- Full page load time
User Engagement
When enabled (default), tracks:
- Scroll depth milestones (25%, 50%, 75%, 90%, 100%)
- Time on page and active time
- Page visibility changes
- Click tracking and rage click detection
- Form engagement (focus, changes, submissions, abandonment)
Error Tracking
- JavaScript errors with stack traces
- Unhandled promise rejections
- Resource loading failures (images, scripts, stylesheets)
Device Information
- Screen size and device pixel ratio
- Device memory and CPU cores
- Network connection type (2G, 3G, 4G, 5G)
- Touch capability
Platform-Specific Installation
WordPress
Use a header scripts plugin, or add to your theme's functions.php:
function vitalsentinel_rum_script() {
?>
<script src="https://rum.vitalsentinel.com/rum.js" data-key="YOUR_TRACKING_ID" async></script>
<?php
}
add_action('wp_head', 'vitalsentinel_rum_script');See Platform Guides for the wp_enqueue_script alternative.
Shopify
- Go to Online Store → Themes
- Click ... → Edit code on your active theme
- Open
theme.liquidin the Layout folder - Add the script before
</head>
Next.js
Using the Script component in your root layout (app/layout.tsx):
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html>
<body>
{children}
<Script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
strategy="afterInteractive"
/>
</body>
</html>
);
}React (Create React App)
Add to public/index.html:
<script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
async
></script>Vue.js
Add to public/index.html or your main template.
Nuxt.js
In nuxt.config.js:
export default {
head: {
script: [
{
src: 'https://rum.vitalsentinel.com/rum.js',
'data-key': 'YOUR_TRACKING_ID',
async: true
}
]
}
}SPA Support
The RUM script automatically detects Single Page Application navigation using the History API. For manual control:
// Trigger navigation tracking manually
window.VitalSentinelRUM.startSoftNavigation();This is useful for:
- Custom routing implementations
- Hash-based navigation
- Complex state transitions
API Methods
The script exposes methods for custom tracking via window.VitalSentinelRUM (or the shorter alias window.VSRUM):
Track Custom Events
window.VitalSentinelRUM.trackCustomEvent('purchase', {
productId: '12345',
value: 99.99,
currency: 'USD'
});Mark Points in Time
// Mark when a critical element loads
window.VitalSentinelRUM.mark('hero-loaded');
// Measure time between marks
window.VitalSentinelRUM.measure('hero-time', 'navigationStart', 'hero-loaded');Add Custom Data
// Add data to all subsequent events
window.VitalSentinelRUM.addData('userId', 'user-123');
window.VitalSentinelRUM.addData('plan', 'premium');Event Hooks
// Listen to RUM events
window.VitalSentinelRUM.on('mark', (eventType, data) => {
console.log('Mark created:', data.name, data.startTime);
});
window.VitalSentinelRUM.on('measure', (eventType, data) => {
console.log('Measure recorded:', data.name, data.duration);
});
window.VitalSentinelRUM.on('soft_navigation', (eventType, data) => {
console.log('SPA navigation:', data);
});Force Send Data
// Send all queued events immediately
window.VitalSentinelRUM.forceFlush();Get Debug Info
const debug = window.VitalSentinelRUM.getDebug();
console.log(debug);
// Returns: {
// sessionId: string,
// eventQueue: number,
// marks: Array,
// customData: Array,
// hooks: string[],
// navigationCount: number
// }Command Queue
You can queue commands before the script loads:
<script>
window.VitalSentinelRUM = window.VitalSentinelRUM || {
cmd: function(c) {
this._q = this._q || [];
this._q.push(c);
}
};
// Queue commands before script loads
window.VitalSentinelRUM.cmd(['mark', 'app-start']);
window.VitalSentinelRUM.cmd(['trackCustomEvent', 'page_intent', { category: 'pricing' }]);
</script>Privacy & Consent
Privacy by Default
The RUM script is designed with privacy in mind:
- No persistent cookies by default
- No cross-site tracking
- Session IDs regenerate on page refresh (no persistent identifiers)
- URL sanitization available via
data-filter-query-params
Privacy Options
Enable additional privacy features:
<script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
data-mask-text="true"
data-mask-selectors="true"
data-filter-query-params="true"
async
></script>data-mask-text- Redacts text content in engagement eventsdata-mask-selectors- Masks CSS selectors in click/form trackingdata-filter-query-params- Removes query parameters from tracked URLs
Opt-Out Support
Respect user preferences:
// Check Do Not Track
if (navigator.doNotTrack === '1') {
// Don't load the script
}GDPR Compliance
The RUM script is designed to be GDPR-friendly by default (no cookies, no persistent identifiers). For additional compliance:
- Delay loading until consent is given
- Use sampling (
data-sample-rate) to reduce data collection - Enable privacy options (
data-mask-text,data-mask-selectors,data-filter-query-params)
Troubleshooting
Script Not Loading
- Check browser console for errors
- Verify the tracking ID is correct
- Ensure no ad blocker is blocking the script
- Check Content Security Policy headers
No Data Appearing
- Wait 15-30 minutes for initial data
- Check sample rate is greater than 0
- Verify the domain matches your configured domain
- Enable debug mode to see console logs
Debug Mode
Enable debug logging:
<script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
data-debug="true"
async
></script>Then check your browser console for [VitalSentinel RUM] messages.
Browser Compatibility
The RUM script supports:
- Chrome/Edge 90+
- Firefox 89+
- Safari 15+
- Opera 76+
Older browsers will gracefully degrade without causing errors.
Related
RUM Monitoring
Learn about the metrics and insights available from RUM data
Performance Thresholds
Understand what good, needs improvement, and poor metrics look like
Data & Privacy
Details on data collection, storage, and GDPR compliance
Troubleshooting
Solutions to common installation and tracking issues