Skip to main content
Single-page applications (SPAs) have a different page lifecycle than traditional multi-page sites. The browser does not fully reload on navigation, so the standard autoPageview will only fire once — on the initial load. This guide shows how to handle tracking correctly in React, Next.js, and Vue.

The key difference with SPAs

In a traditional website, every page navigation triggers a full browser reload, which re-runs the SDK and fires a pageview. In a SPA:
  • The page loads once
  • Subsequent navigations are JavaScript-driven (the URL changes, but the page does not reload)
  • autoPageview fires only on that first load
  • You must manually fire a pageview event on each route change

General rules for all SPAs

  1. Load the SDK snippet once — in your root HTML file or root component, not in every page/route component
  2. Call scanova('init', ...) once — in your app’s entry point
  3. Disable autoPageview — manage page view events yourself on route changes
  4. Fire scanova('track', 'pageview') on each route change — using your router’s navigation event or hook

React (Create React App / Vite)

public/index.html — load the SDK:
src/main.jsx or src/App.jsx — init once and track route changes:

Next.js (App Router)

In Next.js App Router, use a client component in your root layout. app/layout.tsx:
components/ScanovaTracker.tsx:

Next.js (Pages Router)

pages/_app.tsx:
Add the SDK loader to pages/_document.tsx:

Vue 3 (Vue Router)

index.html — load the SDK:
src/main.ts:

Common mistakes