Javascript Redirect Code – Redirect Users to Another Page

Every now and then, you’ll want to send one of your users to an external website. You can already do this by using the redirect settings on your publish page. If you are looking to skip to a particular page within your survey, you should use simple survey skipping. However, using those settings, what you will not be able to do is redirect someone to an external website from somewhere in the middle of your survey. In order to do this, you will have to paste some javascript code into your survey.

To get an idea of what you can use this for, let’s say that on the first page of your survey, you were to ask: “which one of the following websites would you like to visit?”

Your answer choices could be:

1) cnn.com

2) myreviewroom.com

3) chide.it

4) twitter.com/fluidsurveys

What you can then do at that point, is use simple survey skipping to send the user to a different page based on their responses to this question. For the sake of example, we will send users to page 2 if they choose cnn.com, page 3 if they choose myreviewroom.com, page 4 if they choose chide.it, and page 5 if they choose twitter.com/fluidsurveys.

Now, what we need to do is paste the following code on each of these pages:

<script type=”text/javascript“>

<!–

/* Set the following variable to the page you would like toredirectto */

var redirectLocation = “http://google.com“;

/* Set the desired wait time (in milliseconds) */

var delay = 5000;

$(window).load(function(){

setTimeout(function(){

window.location = redirectLocation;

}, delay);

});

//–>

</script>

This code must be pasted into a “section separator”. You should then modify the number “5000” to represent the number of milliseconds that the user’s browser should wait before they are redirected to the destination page. You also must specify the destination url by changing the url that currently points to http://google.com in the javascript code. In other words, you have to customize this javascript code on pages 2,3,4, and 5 of your survey.

Aydin Mirzaee

Aydin is currently the Co-CEO of Fluidware where he spends his time focused on product strategy, marketing and growth for the company's FluidSurveys (http://fluidsurveys.com) and FluidReview (http://fluidreview.com) products. Aydin co-founded Fluidware in 2008 and since then it has grown to become a market leader with customers in over 80 countries.

If you could send an email to support@fluidsurveys.com with the link to your survey, we can certainly help you figure this one out! Our support team is super fast and responsive, so you’ll get an answer in no time!

Why would I not just use the Advance Branching Wizard to and the redirect to URL feature instead creating 4 pages and adding this javascript to those pages?.

When I follow these instruction and cut and paste this code into a Section Header for each page I get warning to use javascript type question. I tried to paste into both the question title area and extra description areas (get same warning) and neither ended up working. I tried pasting this code into a javascript type question on each page (both following a Section Heading and with no Section Heading on page)

Hello Doug! I’m sorry to hear that you’re running into some challenges. Can you please send an email to support@fluidsurveys.com explaining your issue and what you’re trying to accomplish? They’ll get back to you as soon as they can and help you out! Thanks for choosing FluidSurveys!