Add cookie-free, GDPR-compliant analytics to your React or Vite app in under 2 minutes. No consent banner required. Works with Create React App, Vite, and any React SPA.
No credit card required and setup in minutes
Replace YOUR_SITE_ID with your Beam site ID from the dashboard.
<!-- public/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My App</title>
<script
defer
src="https://beam-privacy.com/js/beam.js"
data-site-id="YOUR_SITE_ID">
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
Place the defer script in <head> so Beam loads after your React app without blocking render.
// src/hooks/useBeam.ts
import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
export function useBeam() {
const location = useLocation()
useEffect(() => {
// Beam auto-sends a pageview on initial load.
// This hook fires on every client-side navigation.
window.beam?.track?.('pageview', { path: location.pathname })
}, [location.pathname])
}
// Mount it once near the top of your app:
// src/App.tsx
import { useBeam } from './hooks/useBeam'
export default function App() {
useBeam()
return <RouterOutlet />
}
React Router changes the URL without a full page reload, so Beam's initial auto-capture only fires once. This hook re-fires on every route change to keep path-level analytics accurate.
Use this checklist after publish so you know tracking is actually live in production.
Beam is cookie-free by design — no consent UI to build, no GDPR overhead for your SPA.
Beam's tracking script is lighter than a single React component and adds no npm dependencies.
The useBeam hook captures every client-side navigation, so your Top Pages report reflects real user behaviour.
No PII, no fingerprinting, no ad-tech — just page-level metrics your team can act on.
Start free, validate your first pageview, and then scale when traffic grows.