PageView.
Initial page view
The Bily browser script records the initial page view when a document loads. This applies whether you installed the raw script or initialized it through@bilyai/js.
Traditional multi-page sites need no manual page-view code. Each full navigation loads a new document and records its own initial event.
SPA route transitions
Single-page applications do not load a new document for every route. After the router commits a later URL, send:sourceUrl. Run the call after the page title and route state are current.
Skip the initial route and duplicates
Store the current URL before listening for later navigation.route-tracking.ts
onRouteCommitted() to the router’s after-navigation callback. Do not call it once just to initialize the listener.
Framework patterns
React Router
Track pathname, search, and hash changes from one mounted component.
Next.js App Router
Track pathname and search changes from one client component.
Page-view checklist
- The event name is exactly
PageView. - The initial document relies on the automatic event.
- Later browser routes call
track()after the route commits. sourceUrlcontainswindow.location.href.pageTitlecontains the finaldocument.title.- A rerender at the same URL does not emit another event.
Verify page views
Test direct loads, reloads, route transitions, and browser history.