Hope anyone can help me over here to also make this clear for everyone looking for the same kind of information.
After some research I could not find a definitive answer about manually tracking page views in a single-page application without reloading the tracking code.
The _hsq.push([‘setPath’, ‘/about-us’]); and _hsq.push([‘trackPageView’]); lines included in the example are intended to be run when the user changes from the /home page to the /about-us page. This allows you to track new page views without running the tracking code again. In your case, when a user navigates to the /Contact page, you’d run the following: _hsq.push([‘setPath’, ‘/Contact’]); _hsq.push([‘trackPageView’]);
If anyone else stumbles across this page while integrating Hubspot with their React App, I built a page listener component that seems to work OK for me. I’m using React Router and Redux: