How to get a visitor’s location and redirect them to right store for Shopify

Hura Product Showcase Builder

There are many businesses create multiple online stores with Shopify. Each site will serve a specific customer area. And the requirement is “How can I automatically send customers to the right store, based on their country or IP Address?”

Example we have 3 sites:

  • – Customers in the United States
  • – Customers in the Canada
  • – Customers in rest the world

Don’t worry. This article guide you to do that.

We use service of GeoPlugin.Net (GeoPlugin) to detected visitor’s location. GeoPlugin provides a public HTTP API for software developers to search the geolocation of IP addresses. This is the code.

You should embed this code into <head> tag

The result returned includes: IP, country code, country name, region code, region name, city, latitude, longitude, currency code…

We need country code information. You can compare with country codes table at here to know more.

Now we write code to redirect.

In site’s United States

In site’s Canada

and site’s rest the world

If you don’t know write code you can choose one of the apps:

Hura Theme Blocks

You may also like...

4 Responses

  1. Valentin Nicoara says:

    Where exactly should I introduce this code?

  2. Udaya says:


    I tried this code. But its working only for one time. Can please help me on this.

    Its should works for every time.

  3. Mahdi says:

    Did not work for me at all. I put the code below on the theme.liquid file. The only effect was the website would load really slow but ultimately still be in the same site, did not redirect also

Leave a Reply

Your email address will not be published. Required fields are marked *