Web site hosting: Determining the geographic coordinates of visitors to a web site? Their IP Addresses?

How does one determine the geographic coordinates of a visitor to a web site?
Google Adwords can narrow a person's clicks to a particular zip code. How accurate is this?
Clickcease.com does the same thing?  And yet, when I examine the visitor logs of --let's just say as an example-- 1and1.com, There is no geographic coordinate information there.  Where is Google and Clickcease getting this data?
How is Google adwords able to do this?
How is Clickcease able to do this?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Scott Fell, EE MVEConnect With a Mentor DeveloperCommented:
Is your question how "they" do it or how you can do it?

The way you can determine a visitors approximate location is by a reverse ip service  or api.


They all work similar. You will use your server side code to grab the IP of the visitor, then submit the ip to the third party api, then process the response back that can include multiple fields including a lat/lon coordinate, zip, city, st, zip, county, country etc.  

You have to realize the accuracy will not be 100% as IP's can be faked and depending on the location/isp, you will get an exact zip to something near by.

You can also get the location from the browser but this requires getting the user permission.  https://developers.google.com/web/fundamentals/native-hardware/user-location/obtain-location?hl=en

The way you actually use any of this will depend on what you are trying to do.
They are looking up who IP address is assigned to and assuming the location based on who "owns" that address.

Example: They company I work for located in the USA and we have a office in England.  At one time we had a private WAN connection and our only Internet connection was in the USA office.  So when the employees accessed web sites, they would have the IP address assigned to our USA office, so it appears as if they were in the USA.  So they would get ads for services that were no where near them.

If you look up the host name 1and1.com it resolves to  If I do a whois on that address I get that it is assigned to:

OrgName:        1&1 Internet Inc.
OrgId:          11INT
Address:        701 Lee Rd
Address:        Suite 300
City:           Chesterbrook
StateProv:      PA
PostalCode:     19087
Country:        US

So if somebody from 1and1.com was accessing a web server that I ran from that IP address, I would detect they were there.

Just as a F.Y.I, there are DNS servers that also do geo location lookup so that they will send you to a different IP address depending on where the DNS server thinks you are located.
Dave BaldwinFixer of ProblemsCommented:
IP addresses belong to ISPs and hosting companies, almost never individuals.  If you only use an IP address, you will get the location of the company, not the person.  However... Google and others keep track of much more information than that to locate a person.
The IT Degree for Career Advancement

Earn your B.S. in Network Operations and Security and become a network and IT security expert. This WGU degree program curriculum was designed with tech-savvy, self-motivated students in mind – allowing you to use your technical expertise, to address real-world business problems.

brothertruffle880Author Commented:
in Google's and www.clickcease.com's reports they determine the location of people who click on ads down to the block or zip code, how do they do it?
Dave BaldwinFixer of ProblemsCommented:
They keep track of a lot more than just IP addresses.  Anything you enter into a Google account is available to Google to identify you.  They correlate everything they collect in order to identify you for their advertising services which is where they make their money.  They can also correlate with all the public databases that list people by name and address.

You should also know that they don't about everyone, only those that have revealed their info somehow.
brothertruffle880Author Commented:
Hi Scott:
Yes.  How can I do it?
Company "A" -- a local shop-- wants to know the location and other details of who's clicking on their ads. The more accurate, the better.
That's the scenario.
Following the links that Scott gave in his last post.
Scott Fell, EE MVEDeveloperCommented:
Can you explain in short detail what you are doing?

Are you serving ads? or are they buying ads from a 3rd party like google?  If that is the case, use google analytics and adwords to get that information.

If you are serving ads, use a 3rd party service like I suggested.  If you need help with that portion, I suggest opening another question with specifics as to which programming language you are using and provide sample code with what you tried on your own and errors.  If you can't get that far, then you may want to consider using Gigs to hire somebody to do it for you https://www.experts-exchange.com/gigs/ or Live to have short term assistance on a specific part of  your code you need help with. https://www.experts-exchange.com/live/
brothertruffle880Author Commented:
Hi Scott.  I'm using Google Ad words but want to limit my ad's visibility to a small geographic region.  (by zip codes).  Reason I'm limiting my google ad words campaign to a small area?  I don't want to drive a hundred miles for a job.
I was getting fraudulent clicks on my ads and wanted to try and narrow down where these fraudulent clicks were coming from
I subscribed to clickcease which did a good job of localizing the fraudulent clicks and was very interested in knowing how they were able to locate the pranksters/SOB's.
I suspect it was a competing business that was engaging the fraudulent clicking of my ads.

Rather than paying for this service.  I posted the question because I thought that perhaps I could code something that would accomplish the same thing.  I'm not a half-bad programmer myself!

brothertruffle880Author Commented:
This was useful.  Thanks again Scott!
Scott Fell, EE MVEDeveloperCommented:
Adwords already has the ability to limit ads by geography.  If you are buying ads for google to display on other sites, your only option is to filter in Adwords where those ads show up.

In google analytics you can view the location of your visitors and if you link up adwords to analytics you can see exactly where they came from.  Nothing else needed.

If you feel you have fraudulent clicks, you need to let Google know.

Adwords has other filters that can be used and may be not noticed.  Many people fail using adwords because it feels like it should be easy but it is hard to get right.
All Courses

From novice to tech pro — start learning today.