JavaScript Redirect not working


I need to redirect from an LP to our home page. I found in the forum here that I have to add a javascript snippet into Javascript tab. I did that:

However, it doesn’t work. The page is not redirecting,
I can see the snippet in place at the page source, so I did implement it correctly so it seems…

Please help.



Hi Dina, 

Welcome to the Unbounce community. 

Can you please give us a bit more background information on what you are trying to accomplish. 

  • Are you trying to redirect visitors to a different page after a form submission?

  • Trying to redirect a visitor from a click-through page to a new page?

If you give us a bit more details, I’m sure the community here can help you troubleshoot the issue. 



Here is a piece of code that would work, I just tested it: 
(The original code was put together by Mark for this thread and had a delay timer on the redirect)

&nbsp;<br />&nbsp; (function(){<br />&nbsp;&nbsp;<br />&nbsp; &nbsp; // URL for your redirect<br />&nbsp; &nbsp; var url = '<a href="'" rel="nofollow" title="Link:'">'</a>;<br />&nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; &nbsp; window.location.href = url;<br />&nbsp;&nbsp;<br />&nbsp; })();<br />&nbsp;<br />

However, consider all the implications of such redirects on your UX and SEO.


Will it work just as 301 redirect?
To your questions above - I want to redirect a click-thru visitor, just like 301.
The code I used I found in one of the threads here…


Hi Dina,

Can’t you just change the destination URL of the page that the user gets forwarded to on click through?

I’m a bit unclear as to why this needs a piece of custom script rather than just using the Unbounce native functionality?

Sorry if I’m missing something :slight_smile:




No, I cannot:) It can do me harm in terms of SEO (pages already indexed by Google). You should not just change the URL of a page on your web site - but rather make a redirect.
Thank you.


Hi Dina,

I think we are talking cross purposes here.

If you want to route the visitor to a different URL on a click through page, just change the URL that the button the visitor clicks points to.

I’m not suggesting changing a URL on your website, I wouldn’t recommend that without some kind of redirect anyway or SEO safeguarding practice. 

If it’s a click through page… just change the target of the click.




Maybe I misunderstood you. I need a regular 301 redirect - when a person clicks on this URL - it should be redirected to home page. That’s it.


Ok soz,  crossed wires, thought we were talking about a click through landing page as mentioned above… I get a bit scatty on a Wednesday :slight_smile:

Hristian’s code will do the job but I want to just add a couple of  “be careful” points for you.

You can not send a 301 status code via Javascript any page rank of the old location will not be transferred to the new location. 

Some browsers disable Javascript, think about including a link to the destination page in the body of your LP in case the redirect doesn’t fire.

It’s common to show a page that has a message saying, “This site has moved to … Your browser will be automatically forwarded in X seconds. Click here if your browser does not automatically forward you.”. It helps to cover up the “blink” of the page as it loads and the redirect is executed. 

Apologies for the confusion to start with, Javascript automatic redirects for the purpose of 301 or 302 don’t work, but for user experience they are ok.




Thanks so much, Stuart!