Is there an option to capture the URL parameters from the previous page?
For example, prospect visits a product page, clicks through to lead form and submits. I want to know their previous page.
If so, does this have to be done with a custom form, or can I use a previously created WIX form so that I still receive email notifications (with the previous URL) upon form fill?
1 Like
Have a look at the Wix Location API and the Wix Window API and both of their functions.
https://www.wix.com/corvid/reference/wix-location.html
https://www.wix.com/corvid/reference/wix-window.html
As you can easily create buttons to take you back to previous page like this for example.
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
export function button1_click(event, $w) {
const url = wixWindow.referrer;
wixLocation.to(url);
}
Or you can look at using the referrer function to get the previous page and then use additional code to add it to your form on the page, as shown in the example for Wix Window API and the referrer function along with the Wix Storage API.
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 Site tab 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 vistor’s current page in session storage. When the visitor navigates to another page, this stored URL is retrieved as the previous page URL.
// In Site tab
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
let previousPageURL;
$w.onReady(function () {
previousPageURL = session.getItem("page");
session.setItem("page", wixLocation.url);
});
Hi @givemeawhisky
Can you pls tell where is the site tab to place URL session code?
I still don’t understand how to get the previous url…
Just scroll down to find masterpage tab
JJS