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

Sell Online With Shopify
Trusted by millions of businesses worldwide
Sign up for a free trial and enjoy 3 months of Shopify for $1/month on select plans.

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:

Looking for Shopify Experts?

Hura Apps can help you take your store to the next level

Our team of experienced designers and developers can help you create a beautiful, high-converting Shopify store that will drive sales and increase customer satisfaction. From custom design to app development and optimization, we have the skills and expertise to help you achieve your eCommerce goals.

Get in touch

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 *