homepage Welcome to WebmasterWorld Guest from 54.166.66.204
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Finding a user's location
Trying to find the city where the user is located
GoNC




msg:4674739
 4:55 am on May 27, 2014 (gmt 0)

I'm hoping you guys can help me figure out a way to determine a user's city or county (99.9% of our traffic is in the US). I'm sure that it can be done, since Google Analytics breaks down my traffic by city, but I can't figure out how to do it myself.

I tried using ipinfodb.com, but it's really not accurate for my area; I'm in western NC, but it lists me in Ohio. WHOIS for my IP shows that it's registered in Florida, so that's no good, either.

HTML5 Geolocation also misses me by about 200 miles, so that's pretty useless for my needs.

As a sort of last-ditch-effort, I'm searching the hostname for each county's name manually, in the hopes that their IP provider has the county's name. That only catches 1 in 10 users, though ("Embarq" and "Time Warner Cable" are big providers, and don't have the county name in the hostname), so it helps, but not a lot.

Any other suggestions? I'm willing to pay for a database, but I'd rather roll my own script.

 

penders




msg:4674940
 3:34 pm on May 27, 2014 (gmt 0)

Google Analytics breaks down my traffic by city .... HTML5 Geolocation also misses me by about 200 miles


To be honest if HTML5 geolocation (ie. Google location services, depending on browser) is not accurate for you then I struggle to see how Google Analytics will be any more accurate?

Out of curiosity, have you tried different browsers, in terms of HTML5 Geolocation? Chrome, Firefox, ...?

The HTML5 geolocation "position" object should return an "accuracy" (in metres) - position.coords.accuracy - how accurate does it "think" your location is?

Have you tried setting enableHighAccuracy to true - does it make any difference?

[edited by: penders at 3:50 pm (utc) on May 27, 2014]

LifeinAsia




msg:4674944
 3:45 pm on May 27, 2014 (gmt 0)

I've used MaxMind's IP database. They have databases and web services. The free version may not be sufficient for your pruposes, but you can give it a shot.

omoutop




msg:4675691
 10:23 am on May 29, 2014 (gmt 0)

my opinion
If WHOIS shows error data, then there is nothing you can do.
If you are behind a proxy, disable it.
Else, I think your ISP provides boggus/false data.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved