WebmasterID logoWebmasterID
Data quality

Duplicate pageviews in SPAs

Single-page apps often send a pageview on initial load and another from a route-change listener, and on the very first view both can fire for the same URL. Strict-mode double renders, mounting effects that run twice, and duplicate listeners add more. The result is inflated pageviews concentrated on entry pages. This page explains duplicate SPA pageviews and how to fire exactly one per route.

Partially verified

Why the first view doubles

A common SPA setup sends a pageview from the analytics snippet on initial load and also subscribes to the router's navigation event to send a pageview on each route change. The framework frequently emits an initial route event for the landing URL, so both handlers fire for the same first page. Development double-invocation (React Strict Mode) and effects without guards can add yet another.

Because this concentrates on entry pages, landing-page metrics inflate the most.

Firing exactly once

Choose a single source of truth: either send only from the route listener (and suppress the snippet's automatic initial pageview) or send the initial one and skip the router's first event. Guard route-change handlers so they ignore the initial navigation, and make sure effects that fire pageviews are idempotent. Verify with one fresh session that an entry plus two clicks yields three pageviews, not five.

This overlaps with but is broader than the History-change trigger case, which is specific to GTM.

How it appears in analytics and logs

Two identical pageviews for an entry URL at session start usually mean the initial pageview and a route listener both fired, not two visits.

Diagnostic use case

Eliminate inflated single-page-app pageviews caused by initial-load and route-change handlers both firing for the same first view.

What WebmasterID can help detect

WebmasterID can derive route changes from one explicit signal, avoiding the overlapping triggers that inflate SPA entry pageviews.

Common mistakes

Privacy and accuracy notes

Deduplicating views uses URLs and timing, not identity. WebmasterID keeps privacy-safe language and stores no personal identifiers for this.

Related pages

Sources and verification notes

Last reviewed 2026-06-24. Facts are checked against primary/official sources where available; uncertain specifics are marked “Data not yet verified” rather than guessed.