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

  1. Extract the downloaded file above to /wp-content/plugins/
  2. IMPORTANT: Download the latest GeoLite City database
  3. Place it in this plugins directory:
    /wp-content/plugins/jons_geolocation/
  4. Activate the plugin from the WordPress admin page.

Usage Instructions

  1. 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.

  2. 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: 15% [?]

Leave a Reply