Migrate your existing Magento® store to Shopify Plus and receive up to 6 months free! Learn more +

How To Implement Location-Based IP Redirects On Your Shopify Plus Stores

Feb 5th, 2017

Have multiple Shopify clone stores setup but not sure how to force customers to the proper instance?

Once of our clients, BlackClaw, had this exact issue. They had a US-based store for quite some time. Things were going well and they were getting a lot of traffic from their Instagram account. After the first year in business they realized a number of their customers are ordering from the UK and Australia, paying high international shipping fees.

Their solution seemed simple: clone your Shopify store and set up warehouses in the different countries

Your Merchant Success Manager On Shopify Plus

Like most Shopify Plus merchants would do, BlackClaw reached out to their Merchant Success Manager, Hamza Ayach. Within a few hours Hamza was able to work with the Shopify engineering team to clone their US store.

After testing that out they quickly realized they had one major issue...

Customers from the UK were still ordering from their main US site, paying high international shipping fees (not to mention duties) and having to wait weeks for their package to arrive.

BlackClaw knew their must be a way to have people located in the UK be automatically redirected to their UK store (and similarly for Australia). Once again, they reached to Hamza asking for help. Being that it was a more technical request, Hamza was able to coordinate with the Shopify Partner team to find a qualified agency for the job.

The next day, Hamza introduced BlackClaw to our team at OnlyGrowth. Within the same day, our team of Shopify Plus Experts implemented the location-based IP redirects BlackClaw was looking for.

The Code To Set Up Location-Based IP Redirects

The following code snippet should be placed at the bottom of your theme.liquid layout file just above the closing </body> tag:

<script>
jQuery.ajax( {
  url: '//freegeoip.net/json/',
  type: 'POST',
  dataType: 'jsonp',
  success: function(location) {
    // UK -- United Kingdom
    if (location.country_code === 'UK') {
      // Redirect visitor to the UK store
      window.top.location.href = 'http://uk.blackclaw.com';
    }
  }
});
</script>

*You can find country abbreviation codes here

With this solution any time a person based in the UK were to access their US store they would be instantly redirected to the UK store.

Bingo!

Since then, BlackClaw has been able to ship their high-grade products into their customers hands quicker and cheaper thanks to Shopify's multi-store feature and IP redirects.

All that is left is updating some language on their UK store such as changing 'sweater' to 'jumper'.

Are you a high volume merchant looking to add multi-store functionality? Shopify Plus is the platform of choice for over 1,000 merchants!
Want To Know The 15 Tools We Used To Generate Over $24 Million For Our Clients?

This past year, we have tested dozens of products to figure out which ones yield the best results.
Our toolbox contains some of the most impactful tools we found to grow a brand on Shopify.