Skip to content

Single-Page Application (SPA) setup and configuration

In Single Page Applications (SPAs), users can navigate between different pages without requiring the browser to make full page requests. For these types of websites, you want to send a pageview on each virtual navigation event. The tracker can automatically detect and track these events, with no additional integration required.


Getting started with a SPA? Let know, and we’ll activate a version of the tracker that automatically tracks SPA-style page navigation.

How SPA tracking works

Upon request, support will activate SPA autotracking. This version of the tracker listens for virtual navigation changes and sends pageview events when detected.

Under the hood, the tracker listens for various calls to the browser’s history interface.

Is the SPA tracking compatible with my SPA? SPA tracking should work with any common framework, but it has been specifically tested and confirmed for the following:

  • React.js
  • Gatsby.js
  • Next.js

I originally integrated my SPA using dynamic tracking, how can I migrate to the new SPA tracking integration?

This is easy, and only takes a few steps and coordination with the team.

  1. You add a configuration that deactivates SPA autotrack: var PARSELY = window.PARSELY || {}; = || {}; = false;
  2. activates the SPA tracker feature
  3. You update your site to remove dynamic tracking (manual calls to PARSELY.trackPageView() based on history state changes) AND re-enable SPA autotrack (revert the change from the first step)

Last updated: August 16, 2023