Welcome to WebmasterWorld Guest from 50.17.117.221

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Finding a user's location

Trying to find the city where the user is located

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

Junior Member

joined:Jan 9, 2014
posts: 150
votes: 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.
3:34 pm on May 27, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 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]

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

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5550
votes: 24


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.
10:23 am on May 29, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 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.