Avatar of ITsolutionWizard
ITsolutionWizard
Flag for United States of America asked on

get visitor geo location

I am trying to get website visitor geo location. And my research has the following.

1. using html5 geo Javascript but the down side is to request permission (Yes/No) from the website visitor.
2. make a text box and allow the website visitor to enter his/her own address or zip and convert to lat and lng.
3. using IP address and try to convert into lat and lng. but it has issues on the proxy sometime, and using those IP address provider will only return server IP since the codes is resided in the server.

my question is:
1. Do you know any softare vendor that I can pay for subscription fee to get the visitor's geo location? I see some website they can get very accurate information.
2. Or do you know any ways to write code in c#/mvc/javascript to make it working?
HTMLJavaScriptC#

Avatar of undefined
Last Comment
David Favor

8/22/2022 - Mon
David Favor

You said, "I am trying to get website visitor geo location."

There's no way to even guess about this today.

There are just to many NAT'ted IP systems, where many clients connect through some IP in some geo they choose or is chosen for them.

VPNs. Cell services. Etc...

Follow how Google handles this. They let you set your Geo, based on you're physical Geo, rather than connecting IP Geo.

Since you mention zipcode, likely you're targeting US visitors so VPNs + Cell services will be used most by US visitors, so guessing will be highly inaccurate for US visitors.
ITsolutionWizard

ASKER
thanks David.
you are absolutely right. but I see many website has a way to track visitor Geo position. I highly interested in how they can capture it...
David Favor

The correct way to say this is, "many sites track GEO of visitors IP".

Tracking IP Geo is easy + this data is not very useful, as you never know if it's correct... so there's no way to Geo targeted marketing via IP Geo tracking.

Getting IP Geo is fairly easy.

https://www.iplocation.net/ sell their data + many other similar services sell their data.

Or if you'd like a free solution, you can closely approximate IP Geo using a set of DNS lookups + these will also be suspect.

Bottom Line: You can never really tell a visitors Geo. You can only ask them (like Google does) what Geo data view a given visitor will prefer seeing.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
lenamtl

Hi,

There is a service that you can use https://ipstack.com/

I use very longtime ago this script http://lab.abhinayrathore.com/ipmapper/

let me know if this is what you are looking for.

Other stats tools from web hosting company or google webmaster tools & analytics can give you some stats too.
Chinmay Patel

Hi,

I have very recently implemented this for one of my client using https://ip-api.com which is free for non commercial use. For commercial usage please check: https://signup.ip-api.com/

While there is no 100% sure shot result for this problem (as you can see from the comments above), if it is Geo data that you want to use and then show it on a map or want to use it for any other purpose it is as simple as the code shown below in C# (similar code would work in JavaScript as well)

    using System.Net;

 using (WebClient client = new WebClient())
            {
                try
                {
                    string data = client.DownloadString(new Uri("http://ip-api.com/json/"));
                    // process Geo data
                }
                catch(Exception exception)
                {
                    // Handle Exceptions
                }
            }

Open in new window


Regards,
Chinmay.
ITsolutionWizard

ASKER
chinmay,

a question to you. when you put those codes you shown us in the server and the lng and lat will be shown ?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
David Favor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.