Tracking

Page views

How the script and the SDK count page views, also on client-side navigations, and what a page view carries.

1 min read

A page view is an event named page_view. The script sends one when the page loads and on every client-side navigation: it listens to history.pushState, history.replaceState and the popstate event, so single-page apps (Next.js, React Router, Astro with view transitions) count every page without extra code.

It compares the pathname: a change that only touches the query string or the hash (?tab=2, #pricing) is not a second page view, because the page itself hasn't changed. A push to a new path is.

Every page view carries:

  • The path (/pricing), without the query string or hash. Query strings never leave the browser.
  • The referrer, on the first page view after the page loads, when it is another site: its origin and path, also without a query string.
  • The UTM tags of the page's URL: utm_source, utm_medium and utm_campaign.

In the dashboard the path is the page under Top pages, the referrer's host the source under Sources, and the UTM tags the row under Campaigns. A page view without a referrer is "Direct or unknown".

With the SDK

numbers.autoTrack() does what the script does. Without it, send page views yourself:

numbers.pageView()

See the SDK.

On this page

Marks in the margin

  • Note
  • Watch out
  • Updated

Scribes marked doubtful lines in the margin. That practice is called obelism.

Stuck on a step?