Install Piqo with React Router
One snippet in index.html plus a tiny hook for client-side route changes.
- Paste the snippet into
public/index.htmlinside the<head>. - Add a
useLocationeffect at the root of your app to fire pageviews on route change. - Rebuild and deploy.
<!-- public/index.html -->
<script defer data-site="YOUR_SITE_ID" src="https://piqo.app/piqo.js"></script>// src/App.jsx
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
function PageviewTracker() {
const location = useLocation();
useEffect(() => {
window.piqo && window.piqo('pageview');
}, [location.pathname, location.search]);
return null;
}
export default function App() {
return (
<>
<PageviewTracker />
{/* ...your routes */}
</>
);
}Initial page load: already covered by the script itself — the first pageview fires the moment Piqo loads.