How to detect a visitor’s country of origin on your Shopify store

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 a bunch of reasons why you’d want to know what country a visitor is coming from on your website. If you want to detect a visitor’s country of origin on your Shopify store. Please try with the bellow Javascript code.

This Javascript code will return the 2 letter country code. Eg: VN (Vietnamese), US (United States),… You can refer to the article here to know country codes of all countries in the world.


In fact, you must combine with another script to have the feature you want as: block an entire country from hitting your site or country specific redirects.

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...

Leave a Reply

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