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

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.

LIVE DEMO

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.

You may also like...

Leave a Reply

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