Jump to content

Redirect only once to specific page

Recommended Posts

Hi everyone,
Once people arrive on my website, I would like them to be redirected to a specific page but only once. This means once they visited that page and go back to the main page, I don't want them to be redirected again.
So far I used this code : 
<script>
         setTimeout(function(){
            window.location.href = 'https://(mywebsite)';
         }, 30000);
</script>

But this means, once they visited the page and go back to the Main, they will be redirected again and again...

Any code to add to this?

Thanks

Link to comment
4 hours ago, DougM said:

Once people arrive on my website, I would like them to be redirected to a specific page

Instead of redirecting users, have you considered showing users a promotional pop-up?

About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™. 
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!
If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.
Improve your online store with our extensions.

Link to comment
3 hours ago, paul2009 said:

Instead of redirecting users, have you considered showing users a promotional pop-up?

Yes Paul I have tried but for what we need, I can't created a decent pop-up on Squarespace, so I created a Landing page. ( I need not only the email address of the visitor but also their name, phone number and more...)
I would like it to appear after 30 seconds tho.

 

Edited by DougM
Link to comment
14 hours ago, creedon said:

To make the code run only once you could use a cookie or localStorage.

Instead of a one a done situation you may want to get fancier and have some kind of expiration or other way to reset your flag.

Yes, using cookie sounds great but unfortunately I am not good enough in coding. Newbie here.
Do you suggest any?
Thank you creedon

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.