Documentation Single Page App Tracking

Single Page App Tracking

Track page views in single-page applications (React, Vue, Angular, etc.).

Automatic SPA Tracking

PrivacyPulse automatically detects URL changes using the History API. No additional configuration needed!

Manual Page Tracking

If automatic tracking doesn't work for your setup, you can manually track page views:

// Track a pageview manually
pulse.trackPageview();

// Track with a custom URL
pulse.trackPageview('/custom/path');

React Router Example

import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

function App() {
  const location = useLocation();
  
  useEffect(() => {
    // Pageview is tracked automatically
    // Or manually: pulse.trackPageview()
  }, [location]);
  
  return <Routes>...</Routes>;
}