Skip to main content
Timeline: 15 minutes Common for: React, Vue, Angular, Next.js applications

The challenge

Single-page applications change routes without full page reloads. The pixel tracks initial page view automatically – subsequent route changes aren’t captured unless you tell it.

Implementation

1

Install pixel normally

<script>
  fidero.load()
  fidero.init("YOUR_PROJECT_ID")
  fidero.page() // Captures first page view automatically
</script>
2

Call fidero.page() on route changes

React Router:
import { useEffect } from "react"
import { useLocation } from "react-router-dom"

function App() {
  const location = useLocation()

  useEffect(() => {
    // Track page view on every route change
    fidero.page()
  }, [location]) // Runs when location changes

  return <YourApp />
}
Next.js:
// pages/_app.js
import { useRouter } from "next/router"
import { useEffect } from "react"

function MyApp({ Component, pageProps }) {
  const router = useRouter()

  useEffect(() => {
    // Track page view when route changes
    const handleRouteChange = () => fidero.page()
    router.events.on("routeChangeComplete", handleRouteChange)

    // Cleanup listener on unmount
    return () => router.events.off("routeChangeComplete", handleRouteChange)
  }, [router.events])

  return <Component {...pageProps} />
}
Vue Router:
// In your router setup
router.afterEach(() => {
  // Track page view after each navigation
  fidero.page()
})

What this captures

Each fidero.page() call sends a page view with:
  • Current URL
  • Page title
  • Referrer
  • Session context
  • All preserved attribution data
That’s it. Page tracking works the same as multi-page applications – you just need to tell the pixel when routes change.

Next steps