topic Re: How to get visitor's geolocation (i.e. country) using Jquery in Shopify Discussionhttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/689115#M162274
<P>Hi, IP Geolocation APIs can help you get visitors's geolocations.Here is one worth checking out:&nbsp;<SPAN><A href="https://geotargetly.com/ip-geolocation-api" target="_blank">GEOLocation API</A></SPAN><SPAN>. You don't even have to code. Just drop in JavaScript code they provided, and you can get visitor location data(like, country). For currency switcher, by simply setting up rules, one of the same&nbsp;series&nbsp;tools,&nbsp;</SPAN><SPAN><A href="https://geotargetly.com/geo-redirect" target="_blank">GEORedirect</A></SPAN><SPAN>&nbsp;can auto direct visitors to certain URLs . F</SPAN>or exapmle, exampleshop.com?curr=USD (the parameter in the URL depends on which currency they use based on their countries)</P><P>&nbsp;</P><P>Hope it helps!</P>Thu, 26 Mar 2020 13:51:06 GMTMichaelGeo2020-03-26T13:51:06ZHow to get visitor's geolocation (i.e. country) using Jqueryhttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/242811#M74347
<P>Looking for help to set up auto currency switcher too...</P>Wed, 06 Apr 2016 15:46:14 GMThttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/242811#M74347BestChoiceIndia2016-04-06T15:46:14ZRe: How to get visitor's geolocation (i.e. country) using Jqueryhttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/242812#M74348
<P>You need to implement the GeoLocation API:&nbsp;<A href="https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation">https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation</A></P>
<P>Here is a demo, the code is selfexplaining:&nbsp;<A href="http://html5demos.com/geo">http://html5demos.com/geo</A></P>Wed, 06 Apr 2016 18:43:53 GMThttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/242812#M74348Mircea_Piturca2016-04-06T18:43:53ZRe: How to get visitor's geolocation (i.e. country) using Jqueryhttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/519703#M125128
<P><STRONG><A href="https://ipgeolocation.io/" target="_blank" rel="noopener">IPgeolocation</A></STRONG> is one of the best IP geolocation API services. To find the visitor's location, you can use <STRONG><A href="https://ipgeolocation.io/" target="_blank" rel="noopener">IPgeolocation</A>&nbsp;jQuery SDK. </STRONG>For this, you must have an API key. If you don't have an API key, you can also get it by using our free plan by signing up <A href="https://ipgeolocation.io/signup" target="_blank" rel="noopener">here</A>. Internet connection is also needed to run this component.</P><P>&nbsp;</P><P>For installation, add the following scripts in your HTML page:</P><PRE>&lt;script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.0.6/ipgeolocation.min.js"&gt;&lt;/script&gt;<BR />&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</PRE><P>Here is a sample code to use <A href="https://ipgeolocation.io/" target="_blank" rel="noopener"><STRONG>IP Geolocation API</STRONG> </A>using jQuery SDK:</P><PRE>&lt;script&gt;
var ip = sessionStorage.getItem("ip");
var country_name = sessionStorage.getItem("country_name");
var country_code2 = sessionStorage.getItem("country_code2");
if (!ip || !country_name || !country_code2) {
setAsync(false);
setFieldsParameter("country_name,country_code2");
getGeolocation(handleGeolocationResponse, "YOUR_API_KEY");
}
function handleGeolocationResponse(json) {
ip = json.ip;
country_name = json.country_name;
country_code2 = json.country_code2;
sessionStorage.setItem("ip", ip);
sessionStorage.setItem("country_name", country_name);
sessionStorage.setItem("country_code2", country_code2);
}
$(document).ready(function() {
alert("Hello " + country_name + "!");
});
&lt;/script&gt;</PRE><P>&nbsp;<SPAN>The complete source code for this SDK is available at&nbsp;</SPAN><A href="https://github.com/IPGeolocation/ip-geolocation-api-jQuery-sdk" target="_blank" rel="noopener">Github</A><SPAN>.</SPAN></P><P>&nbsp;</P><P><STRONG><A href="https://ipgeolocation.io/" target="_blank" rel="noopener">IP geolocation API</A></STRONG> provides geolocation information in the following languages:</P><UL><LI>English (en)</LI><LI>German (de)</LI><LI>Russian (ru)</LI><LI>Japanese (ja)</LI><LI>French (fr)</LI><LI>Chinese Simplified (cn)</LI><LI>Spanish (es)</LI><LI>Czech (cs)</LI><LI>Italian (it)</LI></UL><P>For more information, you can read our<A href="https://ipgeolocation.io/documentation" target="_blank" rel="noopener"> documentation.</A></P>Tue, 28 May 2019 13:28:26 GMThttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/519703#M125128Ramiz2019-05-28T13:28:26ZRe: How to get visitor's geolocation (i.e. country) using Jqueryhttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/689115#M162274
<P>Hi, IP Geolocation APIs can help you get visitors's geolocations.Here is one worth checking out:&nbsp;<SPAN><A href="https://geotargetly.com/ip-geolocation-api" target="_blank">GEOLocation API</A></SPAN><SPAN>. You don't even have to code. Just drop in JavaScript code they provided, and you can get visitor location data(like, country). For currency switcher, by simply setting up rules, one of the same&nbsp;series&nbsp;tools,&nbsp;</SPAN><SPAN><A href="https://geotargetly.com/geo-redirect" target="_blank">GEORedirect</A></SPAN><SPAN>&nbsp;can auto direct visitors to certain URLs . F</SPAN>or exapmle, exampleshop.com?curr=USD (the parameter in the URL depends on which currency they use based on their countries)</P><P>&nbsp;</P><P>Hope it helps!</P>Thu, 26 Mar 2020 13:51:06 GMThttps://community.shopify.com/c/Shopify-Discussion/How-to-get-visitor-s-geolocation-i-e-country-using-Jquery/m-p/689115#M162274MichaelGeo2020-03-26T13:51:06Z