Deal Ends in:
BLACK FRIDAY SALE – 35% OFF!
HOT SALE>>
conditional redirect

Redirecting Visitors Based on Dynamic Conditions

One of the biggest advantages of If-So is that instead of duplicating pages you can use a single page and simply add or replace a specific piece of content. Nevertheless, in some cases, you might prefer using conditions in order to redirect visitors to a completely different page.

Redirecting visitors based on conditions can be done by pasting the following JavaScript code inside a content field of a dynamic version. 

<script>
window.location.replace("https://www.example.com");
</script>

* Make sure to replace http://www.example.com with the URL of the page you want to redirect to.

Not familiar with JavaScript? No worries, no dev skills are required. Follow these step-by-step instructions and you’ll have a redirection you can implement ready in 1 minute.

Step by step: How to redirect visitors to a different page based on dynamic conditions

  1. On your WordPress dashboard, under If-So, click “Add new trigger”
  2. Name your trigger (optional)
  3. In Version A, select the condition for the redirection
  4. Switch Version A content field to text mode, and paste the above JavaScript code. Make sure to replace http://www.example.com with the URL of the page to which you want to redirect.
  5. Set up the default content. If you want nothing to happen when the condition you have set for the redirect is not met, simply leave the default content blank
  6. Hit “Publish”
  7. Paste the trigger shortcode as high as you can on the page to which you want to redirect.

Optional – If you want to create a smoother user experience you can redirect by embedding the If-So trigger to the page using a PHP code directly in the page template.

Ready to get started?
Try it on your website