Yes, you're supposed to set it manually in your existing pageview hits to Segment.

Basically, in your case, referrer would be just the previous route. If the previous route doesn't exist, then use the document.referrer.

And yes, organically, if your app doesn't have a previous route, then document.referrer may contain an outside url, which is completely fine and expected.

Also, Segment provides pretty neat support for questions like this, so you can confirm with them.

Answer from BNazaruk on Stack Overflow
🌐
Twilio Segment
https://segment.com › docs › connections › sources › catalog › libraries › website › javascript › single-page-apps
Single Page Applications | Twilio
June 25, 2026 - Instead, the referrer value you see in the payload is the value returned by document.referrer directly from the browser, and the url value is the canonical URL on the page. When a user navigates between pages on an SPA website, there won't be a referrer because there is no concept of a new ...
🌐
LinkedIn
https://linkedin.com › pulse › solve-spa-rogue-referrer-ga4-force-updating-document-mirjam-yusufi--mnpgf
Solve the SPA ‘Rogue Referrer’ in GA4 by force-updating the document referrer
January 31, 2024 - Because of the characteristics of an SPA, you might not see which page a user originated from before landing on the current page. In GA4, this information is found under the “Page referrer” dimension. The JavaScript property behind it is ...
Discussions

domdocument - referrer in segment.io analytics.page() in a SPA - Stack Overflow
I am trying to integrate segment.io to work with Angular. My angular app is a SPA so I have to add some code to my components to allow segment to register the page visits. In the code used to regis... More on stackoverflow.com
🌐 stackoverflow.com
reactjs - window.referrer is always empty in react SPA - Stack Overflow
I am developing a single page react application. I want to render different stuff depending on whether the component was opened from inside the application or from an external shared link. I used More on stackoverflow.com
🌐 stackoverflow.com
javascript - Can I get the referrer? - Stack Overflow
I have a website on which I dynamically create Javascript code using ASP.NET handler in which I should add the referrer to a database. I want to get referrer of referrer like so: website1 website2 ( More on stackoverflow.com
🌐 stackoverflow.com
How do I get the referrer's domain/host name using JavaScript? - Stack Overflow
I know I can get the host name of the current page, by simply doing: var myhostname = location.hostname; But how do I get the host name of the referrer? I can get the referrer by var referrer = More on stackoverflow.com
🌐 stackoverflow.com
🌐
Medium
https://mbaersch.medium.com › attribution-problems-in-spas-solutions-and-caveats-9362fbe8ac3a
Attribution Problems in SPAs: Solutions and Caveats | by Markus Baersch | Medium
June 7, 2021 - In order to achieve this, the referrer field of Google Analytics hits is populated by a custom JS variable or a customTask is used to achieve the same goal: Sending the referrer once, persisting the referrer information and discard the dr parameter it in all following outgoing tracking hits as long as the referrer matches the persisted and already sent url. The first — and common — approach uses location and page GA configuration fields or a customTask to preserve the original entrance location with all parameters and just change the page information, when the visitor navigates to other URLs inside the SPA.
🌐
Google
https://developers.google.com › google analytics › measure single-page applications
Measure single-page applications  |  Google Analytics  |  Google for Developers
1 month ago - The key to measuring page views from SPAs correctly is to count page views for each screen a user interacts with and get the page referrer right, so you can correctly trace the user journey.
🌐
Adobe Experience League
https://experienceleaguecommunities.adobe.com › t5 › dynamic-tag-management-questions › previous-page-url-value-on-spa-site › m-p › 678282 › highlight › true
Solved: Re: Previous page url value on SPA site - Adobe Experience League Community - 675509
June 6, 2024 - You're absolutely correct that document.referral will not work. Just for reference for anyone who doesn't know why, this is because an SPA only loads the physical page once (initially), so the referrer that brought you to the site will be maintained throughout the entire visit.
🌐
Adobe Experience League
https://experienceleaguecommunities.adobe.com › home › product communities › adobe experience platform › previous page url value on spa site
Previous page url value on SPA site | Adobe Experience League Community
May 24, 2024 - You're absolutely correct that document.referral will not work. Just for reference for anyone who doesn't know why, this is because an SPA only loads the physical page once (initially), so the referrer that brought you to the site will be maintained throughout the entire visit.
🌐
LinkedIn
https://linkedin.com › pulse › how-fix-ga4-rogue-referral-problem-spa-websites-ortolani-barbosa
How to Fix the GA4 Rogue Referral Problem in SPA Websites
April 4, 2024 - Navigate to another page on your site, and check if the dl parameter has been updated to the URL of the page, while the dr parameter still points to the site you came from. Note: this navigation should be an SPA route change, without a full ...
Find elsewhere
🌐
Adobe Experience League
https://experienceleaguecommunities.adobe.com › t5 › dynamic-tag-management-questions › previous-page-url-value-on-spa-site › m-p › 675865
Previous page url value on SPA site | Community
May 24, 2024 - You're absolutely correct that document.referral will not work. Just for reference for anyone who doesn't know why, this is because an SPA only loads the physical page once (initially), so the referrer that brought you to the site will be maintained throughout the entire visit.
🌐
Salt
https://salt.agency › home › blog › rogue referral – how to fix your ga mixing up paid and organic traffic
Rogue referral - How to fix your GA mixing up paid and organic traffic - SALT.agency®
March 9, 2022 - This is what we need to find out. First of all, you should get acquainted with the rogue referral problem. In short, rogue referral means that Google loses user data and can’t track referral data properly. Simo Ahava has previously provided an excellent solution to this problem on SPA websites.
🌐
WebmasterID
https://webmasterid.com › home › referrers › referrers in single-page apps
Referrers in single-page apps · WebmasterID
June 24, 2026 - WebmasterID captures the entry referrer server-side at first load and associates later in-app events with that original source, so SPA route changes do not blank out or duplicate the channel.
🌐
Medium
https://vytas-sernas.medium.com › easy-fix-for-wrong-google-adwords-attribution-in-google-analytics-rogue-referral-problem-44d813517b42
Easy fix for wrong Google Adwords attribution in Google Analytics (Rogue referral problem)
October 11, 2021 - There is a simple JavaScript command which can clear the referrer, making the next pageview referrer empty… which is basically what happens in non-SPA pages. Since there’s no referrer and no UTM parameters, based on GA’s logic, such page view is attributed to the last non-direct source, which in our case is Adwords, thus solving the problem.