All things Shopify and commerce
Hi!
I need to block several countries from reaching my store. I saw some javascrips in this forum, posted in 2015.
<script>
jQuery.ajax( {
url: '//freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function(location) {
// If the visitor is browsing from the country XYcont.
if (location.country_code === 'XY') {
// Redirect him to the say google.
window.location.href = 'http://www.google.com';;
}
}
} );
<script>
Does this script work? If not, please can ayone share working version?
I know there are apps, but I have enogh expenses already.
Thank you.
Why do you need it?
JavaScript won't stop someone from reaching your store since JS runs when they are already there. If you're just looking to stop regions from buying from you, consider setting up your shipping to not cover those places.
Thanks for info.
I literally want to block access from IPs from specific countries. Redirecting would work too.
Any free apps? Scripts?
Would be very thankful.
Hi Inga!
Try our Geo Targeting app where you can restrict visitors from defined countries to access your storefront by redirecting them to some custom URL or on a mirror page (that look the same but do not have actionable elements). The app can run before <head> tag before the page load.
Please, let us know if it will work for your problem. You will have 14 days of free trial to run tests.
If the app won't work for you, let us know and we'll probably work something out for you. We'll probably add the feature to our app.
Additionally, we have a Custom JavaScript app which is free to install. Use it to run JavaScripts and feel free to contact us for help with snippets via Help.
Hope I could help. Good luck!
My favorite app that can accomplish this is Country and Currency Redirect because of how inexpensive and easy it is. You can redirect users wherever you want based on their location or currency.
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023