Blue Sky Jason Spence wrote an interesting article about Geographic Content and why it isn’t good to write for a specific local audience. I would disagree. In this post, I am going to write about a very specific location: a city – but not just any city, the best city in the world. And I think you might agree with me!

This weekend, I went to visit some old friends in this wonderful city. The city itself was beautiful, the people were extraordinarily nice and the food was great! What city am I talking about? Find out after the jump!


The best city in the world is of course Washington DC! Are you surprised I picked Washington as the best city in the world? Don’t be, its not a coincidence ;) What I did was a little trick called geolocation. Basically, the server takes your IP address and compares it with a database in order to determine what city your IP address belongs to. The accuracy is not perfect though, due to various factors. If you live in a small town, chances are you will be grouped with the closest major city. Or if you are using a proxy server, the location of the proxy server will be used. Or… the database could just be plain wrong.This method also runs into several complications. For one, wp-cache would not work correctly since it needs to generate new data for every visitor, which is why the city is not mentioned until the single post page, which I have put into the exclusion list in wp-cache settings. Also, there may not always be a matching city found, in which case a default city can be displayed (in this case, I set the default to Toronto).

Advantages include the ability to personalize content for your audience. This post may not be the best example but it gives you a general idea of what you can do. Also, you could use this method to automatically determine the weather without having a user select a city. There is also the added benefit of being able to track your visitors to see where they are from (a lot of software do this already).

I’m sure you can come up with many other creative uses for this! I will write a how-to shortly :)

P.S. I actually do agree with Jason in that content specifically targeted to a small local group would not be popular with most of your readers!

Popularity: 4% [?]

24 Responses to “The Best City in the World”
  1. Jason Spence says:

    :smile: :grin: :lol: :lol: :lol:
    That post just put a smile on my face, so I thought I’d throw some smilies on this comment. :lol: :lol: :lol:

    Nice use of the tool!

  2. Frank says:

    It almost worked for me. Although it didn’t quite get the location just right. I am in a fairly large capital city though so there are lots of variables with telephone exchanges and Internet hubs etc.

    It is a cool idea though and I’m sure you’ll get a lot of interest in the plugin.

  3. KellyCho says:

    It didn’t work for me the first time but it did my second visit. Pretty cool!

  4. jonlee says:

    Yea accuracy isn’t that great. I wish I had the money for the professional database :S

  5. drt says:

    When I saw it the first time, I said what the heck is this? :lol: After reading your other posting, now I know. Good job. Will work on the review when I get some free time.

  6. jerry says:

    I must be dumber than a brick, as I can’t seem to get it to work as shown.

    You show as the way to display location.

    I have tried that and then with all !-’s removed and still nothing.

    where oh where did I go wrong?…

  7. Jon Lee says:

    Perhaps it is the font that isn’t clear
    There should be two hyphens after the exclamation mark and before the closing bracket, just like a proper HTML comment!

  8. ttancm says:

    Off by half a planet for me… I’m in Tokyo, Japan and it’s showing Toronto, On…

    :mrgreen:

  9. kaZka says:

    It’s a nice plugin but it must be recoded. I live in Barcelona, Spain, and the plugin has determined I’m from Madrid, although the two cities are very big and famous…
    Nice idea after all! :wink:

  10. Jon Lee says:

    Toronto is the default city if your city can’t be determined :)

  11. Jon Lee says:

    Unfortunately the data is most accurate for North America.. international support is still kind of iffy :S

  12. [...] Jon’s Geolocation Plugin provides a lightweight method to determine a visitor’s location down to a city level based on their IP address. It is a modification of the open source API ported to Wordpress. Demo [...]

  13. ttancm says:

    Might be better to make “Unknown” or something similar be the default?

  14. amazeman says:

    i didnt know that the IP can show the location of a person in the internet…

  15. Jon Lee says:

    You can change the default to anything you want.
    Just open up jons_geolocation.php to edit, all the instructions are there :)

  16. ttancm says:

    Groovy :mrgreen: Now if it gets a bit more accurate and you add the ability to display flags and stuff like the Firestats plugin does it will be really nice =)

  17. [...] the proxy is working, you can go to a site that will display your IP address or location. You can try this post to see if it displays the city of your proxy correctly (ineffective if your proxy and your current [...]

  18. carl says:

    Awesome. Any instructions on how to use for web pages and not just Wordpress?

  19. Jon Lee says:

    I would suggest looking at the MaxMind API here http://www.maxmind.com/app/api
    It gives instructions on implementing their database with different languages including PHP and Javascript

  20. kaZka says:

    Nice! The plugin now detects I’m in Barcelona… International support it’s better now. And it’s true Barcelona it’s almost the best city in the world. I recommend all people hasn’t been here to visit this incredible city and country…

    Well done Jon Lee! :wink:

  21. eddie says:

    hey, i wanna know hot to translate the commenter’s ip to their city and country. i’ve tried to adding the in the loop of comment.php file of my theme, but still doesn’t work. so, please tell me the way

  22. Kojak says:

    Hi Jonlee this plugin is the best. However i have a question. Do search engines picking up the place it is generated as content?

    Kojak

  23. Kojak says:

    Hi the plugin is not working anymore.. Can you please kindly update this plugin? I can give you free backlink on my site if you do… :)

    Regards

  24. Brian says:

    Up to what version of WP does this work with? How difficult would it be to adapt the plugin to be used not for displaying the location, but rather using the location to determine what content is displayed? We operate a studio that serves two parts of the US. I want our midwest clients (Chicago, Milwaukee, Minneapolis) to be able to see content that is relevant to them, while the west coast clients (San Fran, San Jose) (and others abroad) see the primary content. It would seem like a relatively easy adaptation.

  25.  
Leave a Reply