Docs
React
One script tag in your HTML entry point covers the whole app, including React Router navigations. Takes about two minutes.
Add the snippet
Add the script to the index.html in your project root (Vite) or public/index.html (Create React App), just before </head>:
<script defer src="http://localhost:3000/analytics.js" data-website-id="YOUR_TRACKING_ID"></script>Client-side routing
Nothing else to do. The script hooks pushState, replaceState and popstate, so React Router and hash routing are tracked automatically.
Track custom events
Call the global lumen function from any component. Guard it in case the script has not loaded yet:
window.lumen?.("Signup", { plan: "pro" });Verify
Reload your site and open the site's real-time view in your dashboard. The pageview should appear within seconds. If not, see Troubleshooting.