How do we track page views in a Single-Page App (SPA) with HubSpot?

We added the HubSpot tracking code to our SPA. It works when the page reloads, but it doesn’t track views when users navigate between different parts of the site without a full reload.

Has anyone set this up successfully? Is it best to call something like _hsq.push([‘setPath’, ‘/new-path’]); _hsq.push([‘trackPageView’]); whenever the route changes?

Any tips, best practices, or code examples would be really appreciated!

Hey @Akhi123 :waving_hand: This gets on the edges of my skills, and I think you are on the right path with your route change idea.

Looking at past posts and some Googling, you need to hook this into your router’s navigation events.

Please let us know how you get it working, as I’m sure other folks have gotten stuck here too.

Talk soon! — Jaycee