Ok so basicly here is my script:
window.onload = () => {
enter code here if (first_time) {
window.location.href = "www.netlify.app/teamadventures.signup";
}
}
I want to make it so that if it’s your first time on the website you get taken to a signup page automatically. How do I do this with vanilla JS?
>Solution :
You can use cookies or localstorage for that. The localstorage is the easier method. First check if theres something stored on it with getItem. If not, store this information (the user visited the page) in local storage and redirect to the Sign Up.
var first_time = localStorage.getItem("first_time");
if (!first_time){
localStorage.setItem("first_time", 1);
window.location.href = "www.netlify.app/teamadventures.signup";
}