Mechphisto
11-17-2011, 03:51 PM
Hello,
We need to get a really good idea of what state (of the U.S.) the visitor to our Web site is browsing from. We realize it can't be perfect, but we just need to get a good idea. Our host's logs/analytics isn't that granular, so I'm hoping to add some scripting into our site to pull it.
Is there something better than $_SERVER['REMOTE_ADDR'], because that seems to give incorrect info a lot! We kind of want to get incorrect info just occasionally. :)
I see that Google Maps is doing something where they can locate you extremely accurately! I looked into it:
https://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
but I can't reverse engineer this so that all it does is output as a string the state. I don't want the map, just to be able to pull the state so I can stick it into a database.
tl;dr: Can anyone point me to some example script that will allow me, with reasonable accuracy, to get the state of the U.S. the browser is in?
Thanks!
We need to get a really good idea of what state (of the U.S.) the visitor to our Web site is browsing from. We realize it can't be perfect, but we just need to get a good idea. Our host's logs/analytics isn't that granular, so I'm hoping to add some scripting into our site to pull it.
Is there something better than $_SERVER['REMOTE_ADDR'], because that seems to give incorrect info a lot! We kind of want to get incorrect info just occasionally. :)
I see that Google Maps is doing something where they can locate you extremely accurately! I looked into it:
https://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
but I can't reverse engineer this so that all it does is output as a string the state. I don't want the map, just to be able to pull the state so I can stick it into a database.
tl;dr: Can anyone point me to some example script that will allow me, with reasonable accuracy, to get the state of the U.S. the browser is in?
Thanks!