Search.../

referrer

Gets the HTTP referrer header field.

Description

The referrer is the address of the previous web page that the user was on before arriving at the current page, typically by clicking a link.

Note: When visitors move from page to page within your site, the referrer property does not contain the address of the page the visitor came from. This is because Wix sites are built as single page applications. To get the previous page a visitor was visiting within your site, you can use wix-storage-frontend to store the visitor's current page and retrieve the visitor's previous page.

Type:

stringRead Only

Was this helpful?

Get the referrer information

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5let referrer = wixWindowFrontend.referrer; // "http://somesite.com"
Get the previous page within a Wix site

This example demonstrates how to use session storage to know which page is the page a site visitor previously visited. The code below needs to be placed in the masterpage.js file so that it runs on all your site's pages. The code retrieves the URL of the page a visitor previously visited from session storage. It then stores the URL of the visitor's current page in session storage. When the visitor navigates to another page, this stored URL is retrieved as the previous page URL.

Copy Code
1// In Site tab
2
3import {session} from 'wix-storage-frontend';
4import wixLocationFrontend from 'wix-location-frontend';
5
6let previousPageURL;
7
8$w.onReady(function () {
9 previousPageURL = session.getItem("page");
10 session.setItem("page", wixLocationFrontend.url);
11});
12