Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 5
Carysadauskasdesigns

Redirect to another page in my site after submitting a form?

Question

Is there a way to automatically redirect my visitors to a different page in my site after they have filled out and submitted a form? I don’t want the page to go to the generic ‘Thank you’ message, but instead automatically go to a different page.

Any thoughts?

Edited by Carysadauskasdesigns
Tidy

Brooklyn based freelance graphic designer, and SquareSpace enthusiast.

Share this post


Link to post

22 answers to this question

Recommended Posts

  • 1

The following code seems to work. Replace “/” with the relative link you want the redirect to go to. If you want to link to an external site you’ll need to enter a full url of the format

http://www.somewhere.com/somepage.htm

The code should be inserted in the injection point for the form page:


<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
var eventposted = 0;

$(document).ready(function() {
 $('input.button').click(function() {
   window.setInterval(foo, 100);
 });
});

function foo() {
 if (($(".form-submission-text").is(':visible')) && (eventposted == 0)) {
   window.location.href = "/";
 }
}
</script>

Edited by silvabokis
Tidy

Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 1

Thinking laterally.. ..why not change the Thank you message to set the user's expectations:

"Thanks for getting in touch.. ..you will be automatically redirected to my blog page in a few seconds. To get there quicker, click this link... "


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

I think you could adapt the code in the link above to fire off a page redirect once the form submission DIV is made visible.


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

Thanks! I inserted it just as you said, and it works.... sort of.

When I fill out the form, it still takes me immediately to the same thank you message, but it'll simultaneously try and slowly load the linked page (which is my blog page.) You can actually watch the little 'loading page' wheel on the website tab in the browser (I'm using Chrome) - it spins and skips a few times (it looks kind of glitchy) and then after about 15 seconds of that, it loads the page.

I've tested it about 4 times and it's doing the same thing each time. All the rest of the pages are loading just fine, without hesitation. It's just this one redirect that is lagging. Any idea what may be causing this?

Thanks again for your help!


Brooklyn based freelance graphic designer, and SquareSpace enthusiast.

Share this post


Link to post
  • 0

You'd expect it to load the thank you message, because the redirect only happens once the DIV that holds the message becomes visible.

When I tested it on my site there was a gap of a second or so before the redirect happens, I can't think of any reason that the code would be responsible for any delay.


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

Ok, well, I suppose I'll try it on a few different machines to see if it still does it. I've tried it several more times now, and there's still a very long delay after you submit, before the redirect page opens.

hmmmm....


Brooklyn based freelance graphic designer, and SquareSpace enthusiast.

Share this post


Link to post
  • 0

The bulk of it was posted on here.

I adapted it to add a condition to prevent it firing off multiple events and to insert the redirect function to replace a function that posts to Google Analytics.


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

Has anyone figured out a better work-around for this? I tried the above script and same issue - long delay, although it does work. Any updated script or other suggested solution would be great!

Thanks.

Share this post


Link to post
  • 0

Here is a better fix for you, this works every time for me! Simply replace "YOUR URL HERE" with your URL.


<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">  
   var eventposted=0;  
   $(document).ready(function(){
       $('input.button').click(function() {
           window.setInterval(foo, 100);
       });
   });
   function foo(){
           if(($(".form-submission-text").is(':visible')) && (eventposted==0)){
             eventposted = 1;
             window.location.href = "YOUR URL HERE";
           }
   }
   </script>


Edited by arronphillips

Share this post


Link to post
  • 0

I didn't manage to make it work, either the srcipt, the links, my setup, something is not working, and I'm just tired of this.

So developers, please make this feature part of the form submission features.

Edited by olee22

Share this post


Link to post
  • 0

I have tried this code and it is not working, is this snippet not comparable with a light box form? Or is it not compatible with a landing page?My form is set to light box on a landing page, thus my confusion.

Share this post


Link to post
  • 0

The code I posted was written before the light box form option existed. I'll have a look at making a script that works with both form types (and maybe add to cart) bit it's going to be sometime next week before I'll have time to work on it.

I need it for a couple sites - one of mine and a client's site - so it will definitely get done sooner rather than later.


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

@silvabokis has the right code. I discovered that if you are using your form in a lightbox within an index you need to apply his code in the code injection space in the main settings or inside the site.region file if you're in developer mode.

This twist on his solution wouldn't work if you have various forms throughout the website that all need their own redirect page. I'm using this for conversion tracking and retargeted advertising, so I'm just redirecting every form submission to www.mybaseurl.com/# and inputting that as my "converted" url.


Raise Capital Faster: Reaching More Investors with the Power of Technology

Share this post


Link to post
  • 0

This worked right away. The video demonstration in addition to the step by step instructions on your site made this extremely easy to do. I attempted 3 other codes/plugins before I found yours that did not work.

Share this post


Link to post

Create an account or sign in to comment

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


×
×
  • Create New...