Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

GA4 UTM attribution and Next.js single-page-app page views are two separate problems. Preserve campaign parameters and make sure GA4 sees them when the landing session begins; then configure route changes to send exactly one virtual page_view each. A route-change event can fix missing page views, but it cannot restore UTM values that were removed before GA4 collected them.

Why UTMs and SPA page views fail differently

A campaign link can arrive with utm_source, utm_medium, and utm_campaign. GA4 maps manual UTM parameters to manual traffic-source dimensions, so the tagged landing URL and the first analytics collection matter for campaign attribution: Google Analytics: traffic-source dimensions and Google Analytics: manually tagged URLs.

GA4’s session_start event carries attribution information such as GCLID, UTM parameters, and referrer. If a redirect or page logic strips the query parameters before collection, a later internal navigation does not recreate the campaign context. Separately, Next.js client-side navigation can change the visible URL without loading a new document. If the setup measures only document loads, those later views can be absent; if automatic history measurement and custom route events both fire, views can be duplicated. See Google Analytics: sessions and Google’s SPA measurement guide.

1. Check the tagged URL and every redirect

  1. Inspect the campaign link. Confirm the destination URL includes the intended utm_source, utm_medium, and utm_campaign. Use a consistent naming convention; parameter values that differ in capitalization can fragment reporting into separate values.
  2. Follow the full redirect chain. Compare the original campaign URL, each redirect destination, and the final URL visible in the browser. Check marketing redirectors, shorteners, middleware, proxy rules, and client- or server-side redirects for query-string removal.
  3. Confirm the tag can collect the landing session. Verify the Google tag or GTM container is present and runs on the landing page while the campaign parameters are still available. Google identifies redirects, JavaScript behavior, and server-side processes as possible causes of parameter loss: Google Ads: troubleshoot tracking templates and redirects and Google Analytics: troubleshoot direct traffic.

Direct/(none) is a symptom, not a diagnosis. It can accompany missing tags, stripped parameters, direct or offline visits, shorteners, or ad blockers. Trace the landing path before attributing the problem to the Next.js router. Changing route tracking does not retroactively restore campaign values that were absent when the session was collected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Choose one route-change page-view method

First determine whether the current Google tag setup already measures browser-history changes. Google documents both automatic history-based collection and manual virtual page views; there is no universally best choice across all Next.js and tag-deployment setups.

Consideration Automatic history-based collection Manual route-change events
Existing setup Suitable when the configured tag observes history changes and the resulting events are verified. Useful when the implementation deliberately observes route state and sends virtual page views.
Duplicate risk Can duplicate views if custom route events also send them. Disable corresponding automatic history-based page views before manually sending events.
Page URL and referrer handling Depends on the tag configuration and collected values. Requires deliberate handling of values such as page_location; avoid inventing page-referrer behavior without checking the chosen integration.
Validation Check route transitions and event values in DebugView. Check each manually triggered event and its page_location in DebugView.
Maintenance fit Depends on whether the deployed tag reliably detects the app’s history changes. Depends on router type, client-side instrumentation, and how tags are deployed.

Google’s GTM pattern uses a history-change trigger, updates Google Tag configuration while suppressing an immediate duplicate page view, and then sends a GA4 Event tag for page_view. That guide says not to include page_referrer in its update example: GA4 tracks the original external referrer on initial load and can populate the previous virtual URL for navigation pathing. Treat this as a documented GTM pattern, not a universal snippet for every Next.js architecture: Measure single-page applications with Google Tag Manager.

3. Observe App Router navigation in Next.js

For the App Router, Next.js provides usePathname to read the current URL pathname in a Client Component. An effect can respond to pathname changes, and useSearchParams can be included if the application treats query-string changes as distinct page views. See Next.js: usePathname.

  • Decide whether search-parameter-only changes represent a new page in your reporting model; do not include them automatically if they are merely filters or transient state.
  • Ensure the initial document-load page view is not sent a second time by the route effect. This is a common boundary to verify when combining an existing Google tag with custom client-side instrumentation.
  • Account for rewrites: the prerendered source path may differ from the path visible in the browser. Keep hydration-sensitive UI or instrumentation aligned with the client-visible route.
  • Check the project’s installed Next.js version and existing analytics integration before adapting examples. The Next.js third-party-libraries guidance cited here is versioned for Next.js 14: Next.js 14: third-party libraries.

4. Verify landing attribution and route events in DebugView

  1. Open the site through a representative campaign URL with UTMs, and verify the first collected session begins while those parameters are still present.
  2. Navigate through representative internal routes. Check that each intended transition produces one page_view, not zero or two.
  3. Inspect the event’s page_location to confirm it matches the expected browser-visible URL. Test query-string changes according to the page-view policy you chose.
  4. Test the tagged landing separately from internal navigation. A healthy page-view count alone does not prove the first session captured campaign attribution.

Google recommends Preview and DebugView validation for SPA measurement: Google’s SPA measurement guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Use the traffic-source scope that answers your question

GA4 traffic-source dimensions have different scopes. They should not be treated as interchangeable measures of the same attribution question. Google explains the distinction in traffic-source dimensions, scopes, and attribution.

Question Dimension scope to inspect What it represents
How was this user first acquired? First user source/medium User-scoped acquisition.
Where did this session come from? Session source/medium Session-scoped acquisition.
Which source receives credit for a key event? Event-scoped attribution dimensions Credit assigned under the selected attribution model; data-driven attribution is the default.

GA4 uses paid and organic channels last click for user- and session-scoped dimensions, while event-scoped dimensions use the selected attribution model. A difference between these reports can therefore reflect scope and attribution rules rather than a broken route event.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.