How to get IP address of visitors on your Shopify store
Detecting the IP address of your website’s users is useful for a variety of reasons. In this article you’ll learn how to retrieve the user IP easily with a couple of tricks.
We are using service from jsonip.Com (JSonIP) to get IP address of visitor.
The below Javascript to helps you get IP address of a visitor.
1 2 3 4 5 6 7 | $.getJSON('https://jsonip.com/?callback=?').done(function(data) { var ip_address = window.JSON.parse(JSON.stringify(data, null, 2)); ip_address = ip_address.ip; //Execute Your Code alert(ip_address); }); |
I hope it’s helpful for you.
Happy coding!
Hi, where do we post this code and view the results? Thank you
Salut, ou ajouter le code donner?
For a more simple solution, you could consider installing an IP block app on your store.
Blockify ‑ Fraud IP Blocker https://apps.shopify.com/region-restrictions
It has the Pro report feature that basically gathers all data of IP visitors of your site. You can even filter the data by timeframe, type of IP ( (VPN, Proxy, Residentia…), and device. It helps you detect malicious IPs and block all of them (manually or automatically, it’s up to your setting). Plus, you can lock all of your content n photos so that no one can copy them. They have other cool stuff but these are the ones I use the most.