Geolocation Redirects (No coding, 2 min setup)

Redirect visitors based on the user's country, state, or city. No coding required.
geolocation redirect

Creating IP-to-location-based redirects using If-So is extremely simple. So simple that you can have your first geolocation redirect up and running in 3 minutes from now.

Step by step: How to create a geolocation redirect

*Elementor or Gutenberg user? This condition can be used to set up a conditional element or block (Learn more: Gutenberg | Elementor).

  1. Download If-So from the WordPress directory (free).
  2. On your WordPress dashboard, under If-So, click “Add new trigger”.
  3. In Version A, select the Geolocation condition and set the locations for the redirect.
  4. Paste the shortcode below in the content field of version A.
[ifso-redirect url='' type='js']

* Read below if you prefer to create a 301 or 302 redirect

  1. Replace with the URL of the page to which you want to redirect.
  2. Hit “Publish”
  3. Paste the trigger shortcode as high as possible on the page you want to redirect.

The result – Users from the locations you have set in version A will be redirected to the page you have set in step 4. 

Why If-So? A premium IP-to-location database. It’s all about accuracy…

The first and most important factor to consider when setting up IP-to-location-based content is the accuracy of the database.

No IP-to-location service is 100% accurate. The accuracy depends on many factors, but one thing is sure, you don’t want to take chances with free databases that are, naturally, much less accurate.

With If-So, you get 250 monthly premium geolocation sessions for free. No signup nor credit card is required. Simply download the plugin and create your first geolocation redirect.

The session amount can be upgraded anytime; read below for more information.

More reasons to use If-So to create Geolocation redirects

  1. No setup – No sign-up, no coding required.
  2. Built-in stats – See how many times each version was displayed and how many conversions occurred as a result.
  3. Block bots – Bots visiting your site might exhaust your session quota. If-So offers an option to log geolocation requests, find the bots, and block them from using sessions.
  4. Location-based pop-ups – Show a pop-up asking users if they want to be redirected.
  5. Cost-effective session count – If-So stores the IP as a session during the user’s visit. When visitors keep browsing the site, it only counts as one session.
  6. Page caching compatibility – Create location-based redirects without giving up on the advantages of cache.

PHP redirects (301/302 redirects)

If you prefer to create 301 or 302 redirects instead of a JS redirect, you can use the shortcodes below instead of the one suggested in the step-by-step guide.

301 (permanent) redirect:

[ifso-redirect url='' code='301']

302 (temporary) redirect:

[ifso-redirect url='' code='302']

301 and 302 redirects do not work with Ajax loading. If you paste the redirection shortcode inside an If-So trigger, make sure to add the parameter ajax=”no” to its shortcode (or use JS redirect instead).

Learn more about redirection shortcodes.

More than just geolocation redirects

If-So offers many other personalization options and geolocation-based options.

DKI shortcodes
Automatically display the user’s country name using a simple shortcode.

Location-based pop-ups
Show geotargeted pop-ups on page load or exit intent.

Location-based content
Create country-specific promotions, suggest a translated version of the page, and more.

Show the user’s country flag
Paste a simple shortcode to display an image or emoji of the user’s country flag.

Location override
Allow users to override the location as detected by our IP-to-location database.

Auto-Local time display
Show an event time calculated according to the visitor’s time zone. 

Extra sessions – a Pro If-So license is not required – Affordable prices starting at $5 per month.

Free version: 250 monthly sessions (same premium IP-to-location database we use for our pro plans).

Extra sessions: A Pro If-So license is not required if you only want to use the geolocation condition. Simply subscribe to one of our affordable geolocation plans, activate the geolocation license on your site, and the amount of the session will be automatically updated.

Geolocation plans start from $5 per month for 10,000 monthly sessions and can be upgraded as needed.



Engagement, User Experience


Browser Language, Geolocation

Realated templates and examples