Location-Based Content

I would suggest checking out a geolocation service to lookup the location of the users IP address, such as freegeoip.net. In order to do this you would need to make a rest api get request either through php or javascript.

To get the ip address of the visiting user you can read in

<?php echo $_SERVER['REMOTE_ADDR']; ?>

then send that off to the restful api at freegeoip.net. Free geoip will give you plenty of daily lookups and can give you the following information as an example from the json api:

{
"ip": "104.37.65.178",
"country_code": "CA",
"country_name": "Canada",
"region_code": "ON",
"region_name": "Ontario",
"city": "Burlington",
"zip_code": "L7M",
"time_zone": "America/Toronto",
"latitude": 43.4191,
"longitude": -79.8544,
"metro_code": 0

}

As you can see you can get the latitude and longitude of the estimated location, as well the region, country, city, and estimated zip codes. Once you have that information, then it’s a matter of checking if the states match your defined regions without requiring the use of “bucket lists” of ip ranges.

I hope this helps.