Single-page apps

Single-page app tracking needs no extra code in CROforce. CROforce notices every route change in a single-page app, sends a page view for the new URL and shows the widgets, popups and tests that apply to it.

On this pageHow route changes are detectedWhat happens on a route changePage titlesSend page views yourselfTracking an action on a route

Updated November 28, 2026

Not set
Find it on the install page of your account. It stays in this browser and is never sent anywhere.

To load the snippet in React or Next.js, follow Install on React and Next.js. This page explains what happens after it's loaded.

How route changes are detected

The SDK watches the browser's history. It reacts when your router:

  • calls history.pushState() or history.replaceState() — how React Router, Next.js, Vue Router and most others navigate;
  • moves back or forward;
  • changes the #hash.

It compares the new full URL with the last one it tracked. Only a real change counts, so a router that calls replaceState with the same URL doesn't create a page view.

What happens on a route change

Feature

On the new route

Page views

A Page View is sent with the new URL and page title.

Campaigns
Widgets from the old route are removed, and the ones whose
page rules
match the new URL are placed.
A/B tests

The old route's changes are cleared and the tests for the new URL run. A visitor keeps their variant.

Popups
,
bars
,
quizzes

Checked again against the new URL.

Session replay

Keeps recording the same visit, and stops if the new URL is on your list of pages never to record.

Page titles

The page view takes document.title at the moment the URL changes. If your app sets the title after it renders the new route, the page view may carry the previous title. The URL is always correct.

Send page views yourself

If you'd rather decide when a page view is sent, turn automatic page views off and send your own event:

JavaScript
entailInsights.init('YOUR_SITE_TOKEN', {
  disable_decide: false,
  capture_pageview: false,
});

// After your route has rendered:
entailInsights.trackEvent('virtual-page-view', { path: location.pathname, title: document.title });
Paste your site token at the top of the page to fill it in.

Your own event isn't a Page View. Reports and goals built on Page View don't see it. Build those goals on your own event instead.

Tracking an action on a route

JSX
import { useEffect } from 'react';

export function CheckoutSuccess({ order }) {
  useEffect(() => {
    window.entailInsights?.trackEvent('purchase', { value: order.total, currency: order.currency, orderId: order.id });
  }, [order.id]);
  return <h1>Thanks for your order</h1>;
}

Frequently asked questions

Do I need to send page views myself in React or Next.js?

No. The SDK detects route changes made through the browser's history (pushState, replaceState, back and forward) and hash changes, and sends a page view for each new URL.

Why do I see two page views for one navigation?

A page view is sent whenever the full URL changes, including the query string and the hash. A router that updates the URL twice — for example adding a query parameter right after navigating — sends two.

Was this article helpful?

Try it on your own site

Add a popup, form or quiz to your site in a few minutes and see what it does for your conversions.