Redirect Based on IP

[ad_1]

Hi everyone.

I wanted to see if you could help me out with a redirect issue I’m experiencing.

I’m currently managing a WordPress site which has a page with a newsletter form on it.

I have to redirect people based on their IP address and have come up with this solution using Fetch and IPInfo API.

`fetch(‘https://ipinfo.io/json?token=tokenGoesHere’).then((response)=>{`

`return response.json();`

`}).then((response)=>{`

`if(response[‘country’] === ‘US’){`

`window.location=’https://usapage.com’;`

`}`

`});`

I’ve tested it and have had other people test it with a US IP address and it seems to be working fine.

The only issue is, about once a month or so, I’m getting sign ups from people within the US, which I should not be getting, because they should be getting redirected to the USA page (which I do not manage).

I have checked their IP addresses and they are indeed from the US (so they’re not using VPNs).

What could be the issue here?

Thanks in advance!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer