// React Router v6: hook returns current location object import { useLocation } from 'react-router-dom' function App() { let location = useLocation() useEffect(() => { ga('send', 'pageview') }, [location]) return (/*...*/) }