Window Referrer always null

Using the following code on a page or even site-wide. The referrer always comes back null. Any ideas? I’m trying to get the referrer so I know whether I should redirect to another page or not.

import wixWindow from ‘wix-window’;
let referrer = wixWindow.referrer;

1 Like

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

It’s not currently published. I did notice that when I tested in preview mode I did get a referrer. However, whenever I would publish the site and test, the referrer always came back null.

Very strange. I’ve been trying this out myself on some of my sites and everything works fine. Could you explain more about your site: pages, general structure, code, whatever.

I’d love to help but I’m going to need more to go on.

Thanks for your help! Basically what I’m trying to do is add a registration page prior to a user purchasing an item. The process would be like this:

  1. User clicks an add to cart button
  2. If the user hasn’t already filled out the registration form, they would be taken to the form. This form is setup with user input elements and is connected to a dataset. I have code on the cart page that sends the user to the registration form, but I would like to only send them there if they haven’t already filled out the form. I’m using to send them to the form.

I thought I could just grab the referrer when a user lands on the cart and see if they came from the registration form or not.

That didn’t work so I thought I would set a session variable in the After Insert hook of the dataset connected to the form, but I could never get the variable to pass through to the cart page.

What’s the best way to solve this?

When published the site can be found at

The URL you posted isn’t live yet so I’m unable to view the site. Please post the URL of the site in the editor so I can take a look.

Thanks for the help!

1 Like

Hi Yisrael,
I have similar use case while having another issue with “referrer”, probably somehow related to the discussed one.
Suppose I have a page On this page I have a button, whose onClick is as following:

export function some_button_click(event, $w) { + ‘/pageB’);

Page “pageB” is router page. In routers.js I have the following code:

export function pageB_Router(request)

let from_url = request.referrer;


The surprising part is that from_url equals to “”.
While I would expect to see there that I’ve arrived from pageA.
Is it my misunderstanding or it is a bug?


Exactly the same problem here; always null in Publish Mode (not in Preview), on all browsers.