Country Specific Redirection

Highlighted
Shopify Partner
44 0 2

Hey Everyone,

Is there a best practice when it comes to redirecting a user to a particular shop. I have a US and non US shop, I would like to redirect the customer accordingly. I'm assuming IP is the best way to do this, but it doesn't work so well for the phone.

Any help is appreciated.

Thank you for your time

0 Likes
Shopify Partner
44 0 2

Anyone have an answer? Any help is appreciated.

Thanks

0 Likes
Highlighted
Shopify Partner
47 1 2

A great app for this is Country and Currency Redirect

 

You can easily set up redirects based on a users location or what currency they use

0 Likes
Highlighted
Tourist
21 0 3

Hi Manatarms,

 

You can redirect your user according to his location by using IP Geolocation API services such as IPGeolocation very easily. IP Geolocation is the technique of finding the approximate physical location of an internet-connected device through an IP address and IP Geolocation API is the availability of this technique in the form of an API.

 

 To redirect the US and non-US users to their specific shop, you have to follow these two steps:

 

  • First, you have to find the location of the user by using the IP Geolocation API service. (For details visit IP Geolocation API documentation)
  • Secondly, after that, redirect him on the basis of his location by using the following code.
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (4 === this.readyState && 200 === this.status) {
var json = JSON.parse(this.responseText);
if (json.country_code2 == "US" && window.location.hostname !== "http://us.exmaple.com"{
    window.location.href = "https://us.exmaple.com";
} else if (window.location.hostname !== "http://exmaple.com"
{
    window.location.href = "https://exmaple.com";
}
}
}
request.open("GET", "https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY&fields=country_code2", false);
request.setRequestHeader("Accept", "application/json");
request.send();

For more information, you can contact support@ipgeolocation.io.

0 Likes
Highlighted
New Member
59 0 0

Hi you are right, IP geolocation services are the best way to redirect a user to specific websites. IP geolocation service can identify the locations of your website's visitors by IP, matching their larger database.

 

When it comes to phone,  the accuracy is not as good as PC. If the phone is on wifi, the accuracy is the same as PC. If it is on mobile network, the tracked physical location will point to the celluar tower the phone connects to, not the phone's physical location. In other words, it works better for broader areas. Generally, it you want to direct your customers at county level, like exampleshop.com, or exampleshop.ca, IP geolocation services usually work well.

 

Here is a great tool you could check: GEORedirect

It auto directs your website's visitors to location-specified webpage URLs, for example, your US and non US shop. The accuracy is 99% on country level, 90% on state level, 80% on city level. The tool is easy to set up. No coding is necessary.

 

Hope it helps.

 

 

0 Likes