Hello,
My name is Kenan
I am a Shopify Developer
and Award-winning UI Designer from London / The UK.

40.758896° N
-73.985130° W


+44 7 393 597 802

kenan@black-rooster.co.uk

Developing a Shopify Theme with Built-in Country Detection

Setting Up Your Shopify Theme

  1. Add Country Detection to your store:
    • Open your Shopify store's admin.
    • Navigate to Online Store > Themes.
    • Click "Edit Code" on the theme you want to modify.
    • Find a theme.liquid
    • Add tihs code after </body> tag
    • If needed, create a duplicate theme to avoid affecting your live site during development.

Implementing Country Detection

  1. Use jQuery for Geolocation:
                                <script>
    $(document).ready(function() {
    var detectCountry;
    jQuery.get('/browsing_context_suggestions.json', (d) => {
    detectCountry = d.detected_values.country.handle;
    console.log(detectCountry);
    });
    });
    </script>
  2. You can get Country Code & Full Country Name :
                                            {handle: 'GB', name: 'United Kingdom'}