FROM CACHE - en_header

detect visitor GEO Location using API or codes Only, no apps please

New Member
4 0 0


Good day


I need any code which i can use for detecting my visitor location, country code or country name using Shopify API or any other tool, and only coded tools

I don't need apps, or any outside plugins, because after detecting the country i will do other codes depends on country type


Please help me ASAP


Replies 4 (4)
Shopify Expert
10921 193 2198

Shopify doesn't offer a geolocation service so you'll need to use an external system or rely on the browsers HTML5 Geolocation feature. Do note that to use the browsers feature will show a browser message asking for permission.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. ★
New Member
4 0 0

thank you for your response

actually, i contacted the support, and they told me that API can detect it ??
I'm wondering if there is code can do this from the shopify api or apps.js file !!

194 3 16

Hi there!


Here is Geo Targetly solution worth checking out.


It provides Geo Location API that can easily access your visitors' location, like country, and country, using simple Javascript variables and geolocation Html tags. For example,


geotargetly_country_name(); //gets visitor country name
geotargetly_country_code(); //gets visitor country code
geotargetly_region_name(); //gets visitor Region/State or state name
geotargetly_region_code(); //gets visitor Region/State or state code
geotargetly_city_name(); // gets visitor city name
geotargetly_lat(); // gets visitor latitude
geotargetly_lng(); // gets visitor longitude 
geotargetly_ip(); // gets visitor IP address

geotargetly_loaded(); // gets called when data is available


function geotargetly_loaded(){
  var country_name = geotargetly_country_name();
  if (country_name == "United States"){
      //do something


You don't even to code yourself, but simply drag in Javascript code they provided. Hope it helps!


New Member
1 0 0

Hi there,

thank you for the code you provided. I am kind of a beginner on this and would really appreciate if your tell me where exactly I should place the code?
Also, is it possible to add a map with a small cursor that is shown to customers, so that they approve the location that is determined automatically and move it to the correct exact location if it was not very exact?

Thank you in advance.