Will analytics count page changes in my single-page app?

Yes, if your router changes the address with the History API. The PostDeploy Analytics script sends a pageview on load and on each single-page navigation, so /pricing and /docs show up as separate pages. Routes that change only the #fragment stay one page, and query strings other than utm_source and utm_campaign are dropped.

Last updated 26 November 2026. By Paul Badarau.

A fictional documentation app is a single-page app with routes such as /, /guides/setup and /changelog. When a reader clicks a link, the router calls history.pushState and the page never reloads.

The script wraps history.pushState and history.replaceState, and listens for popstate, which the back and forward buttons fire. Each time the address changes, it cuts the address down to the path plus any utm_source and utm_campaign, and sends a pageview when the result differs from the last one. A filter that writes ?tab=yearly into the address sends nothing new, and /search?q=a and /search?q=b both count as /search.

  1. Put the snippet once in the HTML shell, the index.html or root layout that every route shares. Do not render it from a component. Two copies send two pageviews for every page.
  2. Deploy, click through three routes on the live site, and open the Project's Pages report for Today. Each route should have its own row.
  3. To make a route a goal, add a goal with the matching rule Exact page path. Page goals match routes the same way they match full page loads.
  4. For a step that does not change the address, such as a dialog or a tab kept in memory, add a named event goal and call postdeploy.track with its name.

In PostDeploy Analytics, a bounce is a visit with exactly one pageview and no goal completion, so a visit that moves through two routes is not a bounce.

A redirect inside the app counts as a page. If the router sends a signed-out reader from /dashboard to /login with replaceState, the report shows a pageview for each path, though the reader only saw the login form. Such a visit also stops being a bounce. If your app redirects on load, pageviews per visit read high and the bounce rate reads low.

The product page for this is Analytics.

Start your 14-day free trial