Is it possible to have a visitors redirected to different pricing page based on their IP address? One for USA and another for UK?

I tried different approach, as I couldn’t figure out how to use Wix Router (I couldn’t find enough and good sources about it); It is not optimal but it works.

  1. I created two separate e-stores (for two different countries).

  2. The first e-store is created under the subdomain “country1 . mymaindomain . com”. It has the same products but with different prices. Sometimes, it has different promotions as well.

  3. The second e-store is created under the subdomain “country2 . mymaindomain . com”. It has the same products but with different prices. Sometimes, it has different promotions as well.

  4. I created a Landing-Page with my logo and a welcome message. My main domain is linked to this Landing-Page. So, when people from any country type “mymaindomain . com” they will be taken by DNS to my Landing-Page.

  5. Then, I used the following code in the Landing-Page “masterPage . js” section to automatically identify the location where the visitors are coming from and redirect them to the correct website accordingly.

// The code in this file will load on every page of your site
import wixLocation from 'wix-location';
import {fetch} from 'wix-fetch';
$w.onReady(function () {

// Fetch the user's location details
fetch('https://extreme-ip-lookup. com/json', {
method: 'get'
})

// Check if the request was successful
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
}
})

.then((json) => {
// Set the user's countryCode as a const
const loc = json . countryCode;

// Check if location is from country1
//You have to replace "country1 with the (Internet country domains list (TLDs)) for country country1
if(loc === "country1" ){
// Redirect to  WebSite1
wixLocation . to ("https://country1 . mymaindomain . com");
}

// Check if location is from country2
//You have to replace "country2 with the (Internet country domains list (TLDs)) for country country2
if(loc === "country2" ){
// Redirect to  WebSite2
wixLocation . to ("https://country1 . mymaindomain . com");
}

});

});

I hope this will help…