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

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:

  • www.domain.us – Customers in the United States
  • www.domain.ca – Customers in the Canada
  • www.domain.com – 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:

You may also like...

2 Responses

  1. Valentin Nicoara says:

    Where exactly should I introduce this code?

Leave a Reply

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