Help with country redirect script

New Member
5 0 0

I would like to redirect traffic from certain countries to another store.

I added the script from here, under “Redirect to another store” into the end of my theme.liquid file. However it is not working. Please help!

<script> jQuery.ajax( { url: '//freegeoip.net/json/', type: 'POST', dataType: 'jsonp', success: function(location) { // If the visitor is browsing from Canada. if (location.country_code === 'CA') { // Redirect him to the Canadian store. window.top.location.href = 'http://shop-in-canada.myshopify.com'; } } } ); </script>

0 Likes
Shopify Expert
36 1 8

Please be reminded that free geo ip services usually have quota on the number of request. Another recommendation is not to "force" redirect to another website base on your customer's country, this is adhered to Google guideline and running Google Ads would probably get rejected. Instead, we should show a banner/pop-up to let customer confirm whether to switch the site.

 

We have an app doing the redirection base on customer's ip location, check out GeoIP Redirect Manager: https://apps.shopify.com/geo-ip-redirect-manager

 

Find more about apps for your store.
★ Geo IP Redirect Manager: https://apps.shopify.com/geo-ip-redirect-manager
★ Connected Inventory: https://apps.shopify.com/connected-inventory
★ Theme Save: https://apps.shopify.com/theme-save
We're really good at consulting and customization: support@inscoder.com

0 Likes
Shopify Partner
22 0 0

An easy way to accomplish this would be through the Country and Currency Redirect app

0 Likes