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 me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

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

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.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

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.