Skip to main content

Auto Page View

What is a Page View?

In Matomo, a "Page View" is the most basic event: "The user is now viewing this page or URL."

By default, Matomo tracks this when a page loads.

In Single Page Applications (SPAs), the URL can change without a page reload.

You must tell Matomo about the new URL!


Solution

react-matomo-kit provides:

<MatomoAutoPageView />

Place this component inside your MatomoProvider. It will:

✅ Listen to route changes
✅ Notify Matomo with trackPageView()
✅ Send referrer URL when available


Example

<MatomoProvider config={matomoConfig} debug>
<MatomoAutoPageView />
<App />
</MatomoProvider>

Manual tracking

If you want to manually control page views, use:

const { trackPageView } = useMatomo();

trackPageView();

You can also override the URL:

trackPageView("Custom Page Title", "/my-page-url");