Script for displaying visitor's location?

Status
Not open for further replies.

irideflatland

New member
Dec 23, 2008
369
2
0
Inspired by the Acai blog comments thread...

I was looking at an Acai blog and it says something like - Hi I'm xxxx and I live in xxxx, xx. For me it said Barrons, WI, and I know it said other locations for other people because there were a lot of comments like "Wow I didn't know anyone in my area had tried this".

I don't live in Barrons, WI, but I live nearby. All of those dating ads always say "Find singles in Barrons" so there has to be some sort of script for this.

Does anyone know?
 


Bear in mind that Geo Targeting from IP relies on lookup database, there is no systematic registry like Zip codes, these databases are hodgepodge affairs with inaccurate or completely missing info for some IPs, the ISP web connection point is the actual reported location. my connection is reported to be either a city 20 or 30 miles away.
Here's the Google Documentation, should you want to dig into the API a bit more.

I once subscribed to this IP to Geo info service, at the time it was $20 for 50,000 lookups.
Google has a limit to the number of free accesses per day, it's a huge numbr few of us need sweat.
 
I think the fact that it doesn't report your EXACT city might be an advantage on some pages.

IE, on a berry blog, if the visitor lives in some podunk little town and the copy said: "I just moved to [YOUR CRAPPY LITTLE TOWN]" that could seem a little too unbelievable.

Either way, thanks for this. I'd been trying to figure out a way to get around using maxmind.
 
I use maxmind. $20 for 50,000 lookups isn't that bad. I think you can also buy the database for a few hundreds and update every so often for like $60
 
Last edited:
maxmind offers a free lookup that purposely doesn't give you the user's exact city... which is exactly what I wanted. Here's the code:

Code:
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>

<br>Country Code:
<script language="JavaScript">document.write(geoip_country_code());</script>
<br>Country Name:
<script language="JavaScript">document.write(geoip_country_name());</script>
<br>City:
<script language="JavaScript">document.write(geoip_city());</script>
<br>Region:
<script language="JavaScript">document.write(geoip_region());</script>
<br>Latitude:
<script language="JavaScript">document.write(geoip_latitude());</script>
<br>Longitude:
<script language="JavaScript">document.write(geoip_longitude());</script>
 
  • Like
Reactions: Mr. Websites
I just started using MaxMind using their free database (GeoIPCityLite). The database is updated monthly and I found it to be fairly accurate from my limited testing.

Ip2location.com sucks compared to Maxmind (again from my limited testing).

Google: I was not aware of. I am going to try it out. It might be better choice than maxmind.
 
has anyone tried this?

Doesn't seem to work for me, nor a site that I see an attempt demo'd on.

Jay Ridgeway

(example: google thinks you are located in: (blank) )

edit: ah- it's a wireless broadband card issue.

Thanks for the tip!
Yeah I can't get it to work either.
I got lacrosse's to work though, so thanks for that :)
 
Yeah I can't get it to work either.
I got lacrosse's to work though, so thanks for that :)

Google script is not working. For whatever reasons, it is returning a null object and hence no output.

Intead of the Maxmind Javascript code, I would suggest downloading the GeoIPCityLite database on your server. It is not very big (~30 MB) and you can very effectively use PHP API. This way you don't have to rely on an outside server and lookup will be fast too.
 
Google script is not working. For whatever reasons, it is returning a null object and hence no output.

Intead of the Maxmind Javascript code, I would suggest downloading the GeoIPCityLite database on your server. It is not very big (~30 MB) and you can very effectively use PHP API. This way you don't have to rely on an outside server and lookup will be fast too.

It works great for me
 
Status
Not open for further replies.