Shopify themes, liquid, logos, and UX
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");
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.
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
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.
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.
Hi Everyone!!
A relatively simple and efficient solution is to use IP geolocation JQuery SDK for this purpose.
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
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!
I have 3 solutions for checking country names if match desired country then apply logic.
1.
<script>
let chkcountry = true;
$(document).ready(function() {
$.get( "https://api.ipdata.co?api-key=ADD KEY HERE", function( data ) {
if(data.country_code !== "US"){
setTimeout(function() {
$('.price').hide();
},2000);
}
});
</script>
2.
<script>
$.ajax({
url: "https://geolocation-db.com/jsonp",
jsonpCallback: "callback",
dataType: "jsonp",
success: function(location) {
console.log(location);
if(location.country_code !== 'US') {
chkcountry = false;
$('.price').hide();
}
}
});
</script>
3.
<script>
$(document).ready(function(){
$.get("https://ipinfo.io/json", function (response) {
//console.log(response['country'])
if(response['country'] != 'US') {
$('.price').hide();
}
}, "jsonp");
});
</script>
*Moderator Edit*
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024