Hi all. I am trying to build a mixed webpage on wix, that features both photography and film. Does anyone know of a way to have two complete homepages that load randomly on site visit. So one with a video showreel and one with a photo carousel.
Then on the page’s onReady() function, get a random number:
let num = Math.floor(Math.random * 20);
It will give you a number between 0 and 2 - this will create equal chances for each page - then redirect visitors accordingly
if (num > 0 && num <= 1) {
wixLoation.to(/photography) // photography home page
} else {
wixLocation.to(/films) // films home page
}
To put everything together
import wixLocation from 'wix-location';
$w.onReady(async () => {
let num = Math.floor(Math.random * 20);
if (num > 0 && num <= 1) {
await wixLoation.to(/photography) // photography home page
} else {
await wixLocation.to(/films) // films home page
}
})
NOTE: You should include this an empty home page in the Page code section.