Skip to content

Install Statsdot on React

Updated October 17, 2026

Add the script to the <head> of your HTML file: index.html at the project root with Vite, or public/index.html with Create React App.

<script defer data-domain="yoursite.com" src="https://statsdot.com/js/script.js"></script>

React Router changes the address with the history API, which Statsdot listens to, so every route counts without extra code.

Track events from a component:

<button onClick={() => window.statsdot?.track('Signup')}>Create account</button>

For Next.js, see the Next.js guide.