Jon’s Geolocation Plugin
Overview
Jon’s Geolocation Plugin provides a lightweight method to determine a visitor’s location down to a city level based on their IP address. See an example of this plugin in action. This plugin uses the GeoLite City database from Maxmind. It is a modification of the open source API ported to Wordpress.
Download Jon’s Geolocation Plugin v0.1
Installation Instructions
- Extract the downloaded file above to /wp-content/plugins/
- IMPORTANT: Download the latest GeoLite City database
- Place it in this plugins directory:
/wp-content/plugins/jons_geolocation/ - Activate the plugin from the Wordpress admin page.
Usage Instructions
- Within a blog post, you may place the following HTML comments; they will automatically be replaced with the actual location values (or default location values if none is found).
<!–jgl_city–>
<!–jgl_state–>
<!–jgl_country–>So if you wish to style the location text, simply style around the comment tags, all the plugin does is a straight text replacement.
- If you wish to change the default values, you may do so by editing the default values in jons_geolocation_plugin.php near the top of the file.
Troubleshooting
The correct city doesn’t get displayed!
The city is based on the IP address so it can be wrong for several reasons. If you live in a small town, a nearby larger city may be displayed. if your ISP is in another city, that city may be displayed. If you’re on a proxy server, the IP of the proxy server will be used, so the location of the proxy will be displayed. Finally, the database could simply be wrong.
The same city is always displayed!
This is often the result of a cached page (i.e. using wp-cache). Please turn off caching for the pages you wish to use this plugin on. There should be a field under the caching plugin options to add pages to exclude.
Is anything saved in my MySQL database? Can I keep track of visitor locations?
In short, no. This plugin is focused on being lightweight and fast. You may wish to look at other plugins with more features like Firestats or Geoplugin.
How do I update the database file?
Download the latest version from Maxmind. Overwrite the previous version of GeoLiteCity.dat with the new version.
How can I improve the database accuracy?
You can purchase the much more accurate professional database from Maxmind. You can also use their proxy detection system to detect known proxy servers. Keep in mind it still won’t give perfect readings all the time. You can also use the web API that uses data from the professional database.
Do you take donations? How can I thank you?
I don’t take donations but I do appreciate the following: a linkback, subscribing to my feed, or adding me as a Technorati favorite. However, if you must insist…
Acknowledgments: Maxmind and their Open Source API.
Popularity: 37% [?]
Entries (RSS)
[...] just released version 0.1 of my geolocation wordpress plugin. It is a very lightweight and very simple program. The plugin is located here and an example of its [...]
[...] Jon’s Geolocation Plugin provides a fast and lightweight method to determine a visitor’s location down to a city level from their IP address. [...]
[...] Jon’s Geolocation Plugin | jon lee dot see eh [...]
[...] Jon’s Geolocation Plugin provee un método rápido y ligero para determinar la localidad de un visitante hasta el nivel de la ciudad donde está unicado, por su dirección IP. [...]
[...] Jon’s Geolocation Plugin provee un método rápido y ligero para determinar la localidad de un visitante hasta el nivel de la ciudad donde está unicado, por su dirección IP. [...]
[...] Jon’s Geolocation Plugin provee un método rápido y ligero para determinar la localidad de un visitante hasta el nivel de la ciudad donde está unicado, por su dirección IP. [...]
[...] Jon’s Geolocation Plugin provides a fast and lightweight method to determine a visitor’s location down to a city level from their IP address. [...]
Dear friend,
I am having some problems with your great plugin and I am here to claim for help.
I install it, upload the uptodate data, activate them. But when I insert the html comments inside any post, it crashes. Not just each post, but all the page into body and sidebar divs (just header and footer remain).
Could you help me? I really need your plugin to works because it is the only one that acesse the data variable region/state.
I thank you very very much.
Best regards,
FABRICIO
Hey there, what is the error you get when it crashes?
Hey, dude!
Thanks for the attention!
I get no error message. The page just stop loading where the HtML coments first appears. For example, if in the third post on page I have one of the comments at line 8, all the page is read until that: 8th line from 3th post. It means that, of course, sidebar and footer usually are not loaded because they are called after posts (body section).
Two more question: I am using the most recent free data from Max mind… but I want to know: does the plugin also works with the paid data?
Could it be possible to program a plugin that registers the stats of viewers from predermined states/cities or coordinates?
Well, anyway the important thing is just getting the plugin to work!
Thanks again for helpin me!
Yes it should work with paid data. I’m not sure why it is halting halfway, what version of PHP are you using?
Also, to register stats, try this plug-in: http://firestats.cc/
It’s what I use to get the flags and other logos in the comments. It also uses geo-location and stores every visit into a database.
Nice plugin, I don’t know if I can use it though. Check out mine, I know you are interested in dofollow stuff
Dofollow Trackbacks Plugin
Interesting plug-in but I think the plug-in I use right now removes nofollow from trackbacks already.
I think his plugin removes nofollow from trackback only to avoid comment spam… I think its better…
Will this work if I want to use it to block certain cities instead of displaying the visitor information?
Thanks,
Damian
You could definitely modify the code to do that. However it wouldn’t be foolproof since its not 100% accurate and they could simply use a proxy.
I’m curious, what are you thinking of?
It can totally be done. Certain cities have different ip addresses
Would it be possible to have this plugin pull the IP address of every comment and list what city and country each comment is from?
Hi Jon Lee,
Sure I don’t mind telling you.
I heard that the database from maxmind can be used to block certain IP addresses. A friend of mine is a porn star, and she got a “talk” at her kids school because of what she does. So now she would like to “block” certain IP’s within 150 miles from her town, so that those same people that found her site, won’t be able to see when it’s live again.
I got some of it done, but it blocks countries, not cities; so I know it CAN be done and the code is out there. for some reason I’ve been having a hell of a time getting it done.
Any feedback you can offer, will definitely be appreciated.
Damian
Yes that would be possible but it wouldn’t be very accurate on the city level. Check out the Firestats plug-in. The have support for countries.
http://www.firestats.cc
Yes you can certainly use it in that way. You simply need to look up the user’s IP and check to see if it belongs to a certain city.
This doesn’t work very well unfortunately since IP ranges usually cover a large area. If she is from a large town then it will be effective. Send me an e-mail, I can perhaps help you with the coding.
Jon Lee,
Thank you so much for your help. I just set you a private emial with the information and the steps that I did to start getting the scripts to work. I was able to block a whole country, but I was having difficulties with the cities.
Let me know what other information do you need.
Damian
If you are interested in checking your ip address and your internet information, as well as you browser. Also you cana dvertise on our website, we receive over 1,000 dayily visitors.
You can visit my site at: http://ip-check.org/
[...] Visit [...]