How can I detect a visitor's location for language and currency settings?

Hi all,
I want to detect visitor location, for respective countries, open the desired subdomain(language) and currency.
Help me to find any solutions?

Hi,

There are many IP geolocation services you can choose from.

Here is a list, but these are not the only ones: https://underconstructionpage.com/free-paid-geoip-services/

Please also advise on how to implement this in Shopify Code.

like where to add it. I tried to add other custom code, but nothing works in shopify.

Hi,

follow this:

  1. Go to Online Store->Theme->Edit code
  2. Asset->theme.js->paste bellow code in bottom of file
$.get("https://ipinfo.io/json", function (response) {
    //here you get details in response.
}, "jsonp");
1 Like

Hi, could you explain a little bit more this? Thanks

Run my above code and you get response with current location info so you can store in db or whatever you want. when your customer visit page his API get info of current location.

1 Like

Hi Everyone!!

A relatively simple and efficient solution is to use IP geolocation JQuery SDK for this purpose.

  • You need a valid ‘IPGeolocation API key’ to use this SDK. Sign up here and get your free API key if you don’t have one.
  • Internet connection is required to run this component.

1- Add the following script (CDN link) in your HTML page:

<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.0.6/ipgeolocation.min.js"></script>

2- Use the following example to get the response, add your desired IP address and IP geolocation API key in the following example:

// Get geolocation for an IP address "1.1.1.1"
setIPAddressParameter("1.1.1.1");
getGeolocation(handleResponse, "YOUR_API_KEY");

To get your required parameters, use the examples described in IP geolocation API JQuery SDK.

Regards,

Ramiz

https://ipgeolocation.io

1 Like

Hi, GEORedirect is a tool can auto direct your customers to different webpages with location-specified content.For example, localised currency. It’s easy to set up. You don’t have to code.

Besides, Geo Targetly also provides IP Geoservice API can easily access your visitors’ location, and you could customise subdomains with location-based features.

Hope it helps!

thanks!

If I follow these instructions exactly ad described, where will the IP information of store visitors be found?

Go to Online Store->Theme->Edit code
2. Asset->theme.js->paste bellow code in bottom of file

$.get(“https://ipinfo.io/json”, function (response) { //here you get details in response. }, “jsonp”);

Thank you.

If I follow these instructions exactly as they are, where will we find the IP information of store visitors?

How to insert them on the product page?

like this site

localization.gif

Question : Why is this url (https://ipinfo.io/json) even publically available ? It seems like its a mistake on their part, no? How would they ever even know to bill you after you go past the free plan.

1 Like

They can read the referrer header or your request’s IP and keep track. If they get too many requests, thy return a 429 code and you need to get an API key from them.

1 Like

I have 3 solutions for checking country names if match desired country then apply logic.

Moderator Edit