On this page
What this issue is
page_referrer is a parameter GA4 attaches to page_view events. On a normal site, it is the URL the visitor came from. GA4 reads it from document.referrer, which the browser sets on a full page load.
A single-page app (built with React, Vue, Angular, Next.js and similar) changes the URL with the History API instead of loading a new page. document.referrer does not change. So the next page_view can show the original external referrer, or the wrong internal page, instead of the page the visitor just left.
GA4's Enhanced measurement can send a page_view on browser history changes. It sets the referrer for these, but custom setups, tag managers and router libraries can override or lose it. Results vary by setup, so test yours.
Why it costs you leads or sales
The business impact is low, but it muddies your data. Page paths in reports can look like they came from the wrong place. Path analysis and funnel steps that rely on the previous page become less trustworthy. Internal navigation can also show up as a referral from your own domain if your settings are off.
It rarely stops a lead or sale. It makes it harder to see which pages lead to your form or checkout, so you may make decisions on a wrong picture.
- Landing pageFull load. Referrer is google.com. Correct.
- Route change to /pricingNo reload. Referrer still google.com.
- Route change to /contactReferrer still google.com, not /pricing.
- Path analysisPrevious-page data is wrong.
The page never reloads, so the browser referrer stays at the first value.
How to check if your site has it
Turn on debug mode
Use the Google Analytics Debugger Chrome extension, or Preview mode in Google Tag Manager.
Open DebugView
In GA4, go to Admin, then DebugView, and pick your device.
Click through three or four pages
Navigate using the site's own links, without reloading.
Inspect each page_view
Open the event and compare page_location and page_referrer. The referrer should be the previous page's URL.
Compare with a full reload
Reload a deep page. If the referrer is right only after a reload, your route changes are the problem.
How to fix it
The principle is the same everywhere: on each route change, send a page_view with page_location set to the new URL and page_referrer set to the URL of the route the visitor just left. Turn off duplicate automatic page views so you do not count each navigation twice.
Disable the automatic page_view
In your gtag config, set send_page_view to false so the router controls page views.
Track the previous URL
Store the last URL in a variable and update it after each route change.
Send page_view on each route change
Call gtag('event', 'page_view', {...}) with page_location and page_referrer from your router's navigation hook. See the code below.
Push a custom event from the router
On each route change, push an event such as virtual_page_view to the dataLayer with the new URL and the previous URL.
Create Data Layer Variables
Make variables for the new URL and the previous URL, for example page_url and previous_url.
Edit the GA4 event tag
Use a GA4 Event tag with event name page_view, triggered by your custom event. Add parameters page_location and page_referrer using those variables.
Avoid double counting
In the GA4 configuration tag, turn off the automatic page view, and in GA4 Admin, Data streams, Enhanced measurement, turn off 'Page changes based on browser history events' if you send your own.
Check whether you have a SPA at all
Standard Webflow pages are full page loads, so the referrer is normally right. This issue appears only if you add custom client-side routing or page transitions that avoid reloads.
If you use such scripts, apply the custom code fix
Add the route-change snippet in Project Settings, Custom code, Footer code.
Check for a SPA-style theme or plugin
Classic themes reload pages, so the referrer is normally right. Headless or AJAX page-transition setups can cause this issue.
Apply the route-change snippet
Add it through your theme's scripts or a tag manager, and turn off the duplicate automatic page view in your analytics plugin.
// In your GA4 config, disable the automatic page view:
// gtag('config', 'G-XXXXXXX', { send_page_view: false });
let previousUrl = document.referrer;
function trackVirtualPageView() {
const currentUrl = window.location.href;
gtag('event', 'page_view', {
page_location: currentUrl,
page_referrer: previousUrl,
page_title: document.title
});
previousUrl = currentUrl;
}
// Call once on first load, then from your router's after-navigation hook.
trackVirtualPageView();Before
- page_location: /contact
- page_referrer: https://www.google.com/
- Previous page is lost
After
- page_location: /contact
- page_referrer: /pricing (full URL)
- Previous page is correct
How to confirm it's fixed
- In DebugView, each route change sends exactly one page_view.
- page_location matches the visible URL.
- page_referrer equals the full URL of the previous route.
- The first page of a visit still shows the real external referrer.
- Reloading a deep page still shows a sensible referrer.
- Page counts in Reports do not jump after the change, which would point to double counting.
How to prevent it happening again
- Add a DebugView check to your release checklist for any router, framework or tag manager change.
- Document who owns page view tracking: the router code, GTM, or Enhanced measurement, but only one.
- Re-test after migrating to a new framework, theme or page transition library.
- Keep a note of the previous-URL logic so it is not removed during refactors.
How FunnelGuard handles this
FunnelGuard does not check this yet. Verifying the page_referrer value on each virtual page view is a possible future check, not a current feature.
What FunnelGuard does today is run your real customer journeys on a schedule, check each step, confirm the tracking hits for GA4 and other ad and analytics platforms are sent, and check that test leads reach your inbox and CRM. That can show a missing or broken page-level tag, but it does not judge whether the referrer value is correct.
To watch for this issue yourself, run the DebugView check after each release, or compare a few sessions in GA4 Explore with the Page referrer dimension. A Free plan is available if you want to monitor the rest of your funnel meanwhile, with 1 site and 2 journeys.
Questions people ask
Why is my GA4 page_referrer wrong in a single-page app?
A single-page app changes the URL without reloading the page, so the browser's document.referrer stays at its first value. GA4 can then send that stale value on later page views. Send each virtual page_view with page_referrer set to the previous route's URL.
How do I set page_referrer manually in GA4?
Send a page_view event with a page_referrer parameter. With gtag.js, call gtag('event', 'page_view', { page_location: currentUrl, page_referrer: previousUrl }). In Google Tag Manager, add page_referrer as a parameter on your GA4 Event tag.
Does GA4 Enhanced measurement fix SPA page views?
Enhanced measurement can send page views on browser history changes, which covers many SPAs. Results vary with your router and tag setup, so check DebugView. If you send your own page views, turn that option off to avoid duplicates.
How can I check page_referrer in GA4?
Open Admin, then DebugView, with debug mode on, and click through your site. Open each page_view and compare page_referrer with the page you just left. You can also see the dr parameter on collect requests in the browser's Network tab.
Why does my own site show as a referrer in GA4?
If page_referrer holds your own domain, internal navigation is being treated as a referral in some reports. Add your domain under Admin, Data streams, Configure tag settings, List unwanted referrals. Also check that your virtual page views send the correct referrer.
Will a wrong page_referrer lose me leads?
No, it does not stop forms or checkouts from working. It makes page-path and navigation reports less reliable, so the impact is low. Fix it so your analysis of what leads to conversions is accurate.
Does FunnelGuard check page_referrer?
No. FunnelGuard does not check this yet, and it is a possible future check. It does run your funnel journeys on a schedule and checks tracking hits are sent, so use DebugView to verify the referrer value.
Related issues
- TRK-050Parameter value is undefined, null or '(not set)'Fix guide
- TRK-046Conversion event fires on every page view of thank-you page (refresh)Fix guide
- TRK-049Required event parameter missing (form_id, method)Fix guide
- TRK-044generate_lead fires on page load instead of submitFix guide
- TRK-043generate_lead not sent on form submitFix guide
- TRK-045Lead event fires on submit click even when validation failsFix guide