About MeArchivesHow TosWhat Is?Generate CashCase StudiesMediaResourcesMy SitesAdvertiseNewsletterContact

WordPress Geo Targeting Script

July 9, 2009

Miscellaneous

Updated: July 6th, 2011

Looking for geo targeting capabilities for WordPress and other PHP-based sites and Content Management Systems?

Check out the geo targeting scripts that we have available.

Geo City-Region-Country TargetingIf you want to specify ads ( or other content ) to show to your web site visitors based on the city and/or region (state, province) and/or country they are visiting from, the Geo City Plus Package is for you. It includes BOTH the WordPress Geo City Plugin AND the Geo City PHP Script.

Geo Country TargetingIf you want to specify ads ( or other content ) to show to your web site visitors based on the country they are visiting from, the Geo Country Bundle is for you. It includes BOTH the WordPress Geo Country Plugin AND the Geo Country PHP Script.

Geo Country LiteIf you want to simply show country specific messages, like “We deliver directly to {country-name}!” to your site visitors, this free geo targeting WP plugin will do the trick.

Let’s run through a quick example using the WordPress plugin ( or script ) from the Geo Country Bundle…

A common use of the geo country scripts is to show different ads ( or other content ) in posts, pages, widgets and / or theme files based on the person’s country. The content can be in the form of text, html, javascript and / or php <--- even in posts and pages! See how here.

For example, say you are running an “acai berry” blog or site. You may have an offer / creative for the U.S. only which pays $37.00. You may also have another offer that caters to Canada, the U.S. and the U.K. which pays only $34.00. Before using this plugin, you may have opted for the second offer ( the $34.00 one ) so you didn’t miss out on the U.K. and Canadian traffic. However, the $3.00 extra you would get for the U.S. offer is very important to your bottom line, plus… what about all of the other countries visitors that may drop by? You can monetize that traffic as well with say… some Google AdSense.

So how do you display the correct offer to your visitor? Simple, you install the geo-targeting script ( or plugin ) and run some simple commands when using the script ( or use WordPress shortcodes when using the plugin ) to decide which ads to display. In English you’d say “If this visitor is from the U.S., show the $37.00 offer, if they are from Canada or the U.K. show the $34.00 offer, and if they are from anywhere else, show Google AdSense!”

The plugin and script are both very easy to install and use on WordPress and other php based sites. I created a very thorough step-by-step quick-start guide as well to explain exactly how to use it, plus there are a variety of support avenues to get things going quickly.

Learn More Here

Note: Some of the comments below might relate to prior versions of the geo targeting scripts. Please use the link above for the most recent information pertaining to our products.

, , , , , ,

About Keith Lock

Keith has been in the affiliate marketing field for 10+ years working in a variety of niches along the way. His extensive technical background has allowed him to gain a significant advantage while marketing online. Keith primarily writes detailed step-by-step guides and product/service reviews in the make money online niche.

View all posts by Keith Lock

© Earn A Living Online in Your P-Jizzle's.

Get Exclusive Money Making Tips:

Market Samurai Free

64 Responses to “WordPress Geo Targeting Script”

  1. alan Says:

    Is this easy to install even for someone with zero tech knowledge keith? i have just been accepted by neverblueads and copeac so may purchase this in the future as soon as i brush up on my CPA, looks good

    Reply

  2. Keith James Lock Says:

    Hey Alan, a couple people have followed the instructions and got things working pretty quickly. I give a lot of theory, background and example in the manual, but really the necessary instructions are quick and painless.

    Awesome about NeverBlue and Copeac!

    Reply

  3. Rachel Says:

    Do you have any idea if this script could be integrated into a Drupal website?
    Thanks,
    Rachel

    Reply

  4. Keith James Lock Says:

    @Everyone, just to let you know, the script should work with any php based site, but the instructions are geared towards WordPress.

    Rachel is currently testing it with Drupal and may provide instructions for others to use.. I’ll keep you posted in this spot.

    Reply

  5. plienine Says:

    What about e107 CMS?
    is it possible to add this function to e107 system pages?

    Thank You.

    Reply

  6. Keith James Lock Says:

    @plienine I never heard of that CMS… but I just Googled it.. it runs on PHP so yeah there will be a way to get it to work… full refund if not. I can try and help too if you need some assistance.

    Reply

  7. Joe Says:

    Hi,
    This looks perfect. Nice script!
    Has it been tested on WP 2.9.1?
    Does the price include future updates?
    Thanks
    Joe

    Reply

  8. Keith James Lock Says:

    @Joe, Yep it works in the latest version of WP… it more or less “integrates” with any PHP 5.0 based site, any version of WP included.

    There’s nothing formal in place to keep track of customer purchases to offer upgrades to, but I will be putting something more concrete together as time allows. I will, however, put your purchase notification email aside and send you an email when an update is made.

    Reply

  9. Andy Says:

    Hi,
    What database does this use to perform the geolocation? Is there download/installation of the database required too?

    Finally, how is the geolocation information updated, since location of IPs change constantly?

    Many thanks

    Reply

  10. Keith James Lock Says:

    Hi Andy,

    The database comes from MaxMind. It updates monthly.

    Reply

  11. Tom Says:

    Keith, is this easy to use for amazon links within posts? What’s the syntax for inserting alternative links depending on the country?

    Reply

  12. Keith James Lock Says:

    Hi Tom,

    It’s simple for adding any kind of links, including Amazon links..

    As far as inserting into posts you might have to get creative. One simple solution is to disable the Rich Text editor and install a plugin to allow PHP to execute. http://wordpress.org/extend/plugins/exec-php/

    Then you just use PHP if/then or switch statements from there.

    This might not make sense now but it will after reading the accompanying manual… but be sure to re-declare the $COUNTRY variable within the post to get it to work.

    Also, if using the same bit of code in multiple posts, include statements work well.

    Any of these extras I can help you with if need be.

    Reply

  13. Daniel Jacobs Says:

    Hello.

    I have a site that generates about 30K page views per day. Do you see any performance impact after integrating your script? I desperately need this functionality, but not if it impacts performance.

    Thanks,

    Daniel

    Reply

  14. Keith James Lock Says:

    @Daniel – I have customers that have run smoothly with upwards of 50k+

    The commands are short and quick and the code is clean and optimized. Anymore questions, let me know :)

    Reply

  15. Daniel Jacobs Says:

    Thanks for the quick reply. Do you know if it plays nicely with WP-SuperCache?

    Reply

  16. Keith James Lock Says:

    @Daniel… good question… I have not tested it with any caching software as of yet… Care to test for me? I will issue a 50% refund if it tests successfully.. and 100% if it doesn’t..

    I have to also try W3 Total Cache but have just been soo busy…

    Let me know!

    Reply

  17. Daniel Jacobs Says:

    That sounds fair. I appreciate your honesty!

    Reply

  18. Daniel Jacobs Says:

    Ok, I have the script installed and running. The trouble is, I’m in the US! Do you know anyone that can go to http://www.whatsthatbug.com/2010/02/12/update-we-are-doing-the-final-edits-on-our-book-this-weekend/ from outside the US or Canada? They should see an AdSense ad block below ‘are we experts yet?’. US or Canada should see a 468×60 banner (which won’t be an ad – just an image).

    Reply

  19. Keith James Lock Says:

    @Daniel – can you set it to show AdSense for Canada too.. just for a sec.. then I can test it from here?

    I went to http://au.worldproxy202.com/ to see what it might look like from Australia except it’s showing empty (which is possible when AdSense first gets dropped in)… so maybe a better test is to do what I described above..

    Reply

  20. Daniel Jacobs Says:

    Yeah, it looks like the proxy strips out the ad scripts. It should show Adsense for Canada now.

    Reply

  21. Keith James Lock Says:

    @Daniel… k, I refreshed it and I see a 300×250 AdSense block from here in Canada :)

    Reply

  22. Daniel Jacobs Says:

    But unfortunately, so do I :( Which means WP-SuperCache cached your version first, and that’s what it showed to me. I wonder if we can work around this with a javascript function instead of php for the if/then statement? Any thoughts?

    Reply

  23. Keith James Lock Says:

    @Daniel… oh.. so WP-SuperCache takes recently executed statements (just PHP??) and stores the result to load things quicker for the next visitor??? I didn’t know how it worked.. well…

    off the top of my head I’m thinking maybe we could store the country value into a cookie..then use some javascript.. however.. maybe there’s code before that that will get cached?

    Is there any way to force execution of certain code and ignore WP-SuperCache? let me check…

    Reply

  24. Daniel Jacobs Says:

    Not exactly – it caches the entire page as a static html file. I’m going to poke through their docs. Should we take this conversation to email for a bit until we come up with something?

    Reply

  25. Keith James Lock Says:

    @Daniel… ok… let’s come up with the solution by email then go from there.. I sent a couple already.. (maybe went to spam?)

    Reply

  26. Daniel Jacobs Says:

    Thanks for your assistance, Keith. For anyone who wants this to work with WP-SuperCache, here is what you have to do:

    Follow the regular installation instructions first.

    Then, edit functions.php in your theme’s directory. You need to create a new function that has the if/then logic:

    // checks the geolocation info to not serve pubaccess ads to the rest of the world
    function geolocation_check() {
    global $COUNTRY;
    if ($COUNTRY == ‘US’) {
    $ad_code = “enter your script info (make sure to escape quotes, i.e. \”).”;
    } else {
    $ad_code = “enter your other script info (make sure to escape quotes, i.e. \”).”;
    }
    echo $ad_code;
    }

    You can add multiple elsif calls if you need to.

    And then in single.php (or wherever you want the ad to show up),

    And now my blog shows one set of ads for the US and Canada, and another set for the rest of the world!

    Reply

  27. Joerg Says:

    Hey Keith,

    this looks like a perfect fit for me.

    One question though: which version of the MaxMind database does your script use? To be more specific: do I have to pay any additional monthly amount to MaxMind, or are there no follow-up costs?

    Thanks,
    Joerg

    Reply

  28. Keith James Lock Says:

    @Joerg.. it’s the free version of the DB (99% accurate) from MaxMind.. no hidden fees :)
    A customer sent me a file to automate the update process using a cron job.. let me know if you want it.. I haven’t used it myself and can’t provide support but it may be useful..

    Reply

  29. Joerg Says:

    Hi,

    thanks for the quick reply!

    Now let’s wait and see if my potential client will become an actual client :)

    Reply

  30. mobil bekas Says:

    Hi Keith.
    Is your script capable of hiding Adsense ads based on site geographic visitors. I intend to display adsense ads to visitors from only particular countries and hide them from the rest.

    Thanks

    Reply

  31. Keith James Lock Says:

    @mobil bekas

    Yes.. it can do that very easily :)

    Reply

  32. TC Says:

    Hi Keith,
    How about I want to use this plugin along with other plugin such as ad rotating plugin? Can it work? How do I write the php script?

    Reply

  33. Keith James Lock Says:

    @TC.. It’ll work.. I used it just fine with WP Ads (ad rotator).. how to implement it is laid out in the accompanying manual. It’s really simple, but I’m here to help if you get confused with anything.. Also, there’s a money back guarantee if it doesn’t work for you.

    Reply

  34. bulga Says:

    Hi,

    can this package be used, with minor changes, for the resolution of cities as well? I see that maxmind publishes a lite cities version as well

    Thanks

    Reply

    • Keith Lock Says:

      Hello… I have version 2 coming (just need to write the manual and develop the site).. it allows you to display city and province/state as well. Will be available soon. Keep an eye on this spot.

      Reply

  35. Webster Says:

    Hello Keith,

    I am intersted in your plugin for geo targeting ads for different countries. I would like to know a few things please:-

    1) If I used this on a plain php built website what strain would it have on a free hosted server cpu load. The reason why I am asking this is I used a free open scource script that had geo targeting and my free hosting account got closed due to heavy socket requests from the script. So will this happen with your script if I have a heavily visited website. Will it be a strain on a free hosting server?

    2) Are there instructions on how to impliment it on a plain php built site? I am looking for something that is light on hosting servers but gives good geotargeting for a heavy traffic site showing javascript based ads on a plain .php site.

    3) Can I use it on more that 1 domain I own?

    4) Will the new version be more expensive and when will it be released?

    5) Is there a money back guarentee?

    6) Will this work with the wordpress supper cache?

    7) Does the server need anything for this to work like special php privliges like fopen or anything like that?

    Thanks in advance for your help.
    Webster

    Reply

  36. Webster Says:

    Hello

    Sorry for the double comment. I forgot to ask also does your script slow the page loading time when it is goetageting the ads.

    Thanks

    Reply

    • Keith Lock Says:

      Hi Webster.. thanks for the questions..

      1) The script is fast.. it retrieves data from a binary DB to determine the country and stores it in a variable… I can’t answer whether it will affect the CPU load on a free server as there are too many variables.. I have had no problems with speed on shared hosting accounts with Digg 1st page traffic..

      2) Yes, it includes a manual for php sites, and another for WP

      3) You can use it on all your domains.. you can’t sell it or give it a way, but you can sell or give a way a site with it installed without having to get your customer to pay for a license (that may change with the new version, it’s something we’re considering)

      4) The new version will cost more and will be worth the price. It will be released early in the New Year at the latest…

      5) Yep, you get the standard 90-day money back guarantee.. (it’s on the sales page)

      6) With some tweaks it works with all caching plugins.. there are no instructions in the WP manual to assist with that.. that will be something included in the new version..

      7) If you want to get it to run on PHP4 there may be some things that need to be turned on… but with PHP5 running it’s all good.

      8) I have seen no difference in page load times when running the script… there certainly is nothing noticeable to the naked eye..

      Hope that helps… just give it a try.. if for some reason it fails in any area above for you.. let me know and I’ll give you your money back.. have a good one

      Reply

  37. webster Says:

    Hi Keith thank you for your reply.

    I am sorry for this but I have two more questions.

    Can I pay with paypal?

    Also if I bought your script will the future updates to that script be free of charge?

    Thanks again for your help and sorry for any inconvenience caused.

    Webster

    Reply

  38. webster Says:

    Can I also run many websites from one database or is it advisable to have a new database created for each new site or URL.

    I am seriously thinking of purchasing.

    Thanks
    Webster

    Reply

    • Keith Lock Says:

      Yep, PayPal (and any credit cards that PayPal accepts) is the only method of payment.. The next version will be on ClickBank.. I’m looking at the next one as a whole new product, so therefore no.. no free upgrades. I ran a test where I connected 10 moderately trafficked sites to the same DB (it’s a binary file, not MySQL) and things went smooth.. I don’t bother doing it that way under normal circumstances.. I like to just upload the files, add the include statement, run a command or two and be done with it… rather than adjusting connection strings etc.

      Reply

  39. webster Says:

    Do you have any idea on how much the new version will cost and what does the new version have that is better than the current version at $9.95 as now I do not know which to buy. Should I wait for the new version?

    Thanks
    Webster

    Reply

    • Keith Lock Says:

      Not sure on the new price… we are still looking at data.. however.. we have determined that this current product was better priced at $24.95 rather than $9.95.. but we decided not to change it back because the new one is coming out soon. We are just testing it on some servers right now..

      Say, your visitor is from Windsor, Ontario, Canada.. the program will return:

      City: Windsor
      Prov: Ontario
      Country: CA or CAN or Canada (all in separate variables)
      Also, in some cases it will return latitude and longitude.
      Additionally, you can display a flag icon..

      There will be a TON more usage examples.. and the manual will be smaller than the current one… and there will be an extended manual in the form of a blog that we add to as we go with more ideas..

      So.. it depends what you need it for.. if you are content with just determining the 2-character country code of your visitors then this one is good enough for you.

      Reply

  40. Lee Says:

    Absolutely love the concept of this plugin. I’ll wait until the new version as I’ve got a great idea for the city option.

    But a couple of quick questions:

    Would I be able to run several instances of the geo on the same page? i.e. * 1 for the top banner to show by country.
    * 1 to show a different side bar element (normal html) by country
    * 1 to show some more html content based on UK city?

    Also what would Googlebot see if I install plugin? Ideally I’d like to make sure they saw the content that is default (UK), whilst US humans see the human top banner, and sidebar navigation element.

    Awesome stuff again Keith,

    Lee

    Reply

    • Keith Lock Says:

      Thanks Lee… I’m pretty excited about the launch. I will be relaunching a new version of the GEO Country API bundled with a Geo Country WP Plugin prior to the City API/Plugin but it won’t be far behind…

      you wouldn’t really need to run multiple instances, but you can display as many custom geo-targeted “chunks” of data as you want on as many pages as you want… and it will be highly efficient too…

      Googlebot would behave as a regular user in this case.. depending on the IP address of Googlebot during the crawl would determine it’s geo-location and therefore the content that it sees.. this shouldn’t be manipulated with code or else it would be seen as cloaking. However.. displaying IP-based content is perfectly OK as (what seems to me is) pointed out in this video by Matt Cutts (http://www.youtube.com/watch?v=GFf1gwr6HJw)

      Obviously this may display less than ideal content in the SERPS for city-based content but it should be fine for countries… just set a nice descriptive (and generic) meta description to get around some of the issues with cities..

      Don’t forget to set your main country in Webmaster Tools..

      Hope that answers your questions!

      Have a good holiday… Keith

      Reply

  41. Lee Says:

    Hi Keith,

    That’s great thanks. I’ll keep an eye out for the new version.

    I suppose what I could do is just have the standard UK outlinks and then just supplement it with the US/other nations above. I realised that the links I’d be switching were outbound affiliate ones blocked with robots.txt and rel=”nofollow” so it wouldn’t make a jot of difference to Google anyway – my bad!

    Hopefully we’ll get a nice email via your newsletter letting us know when its available?

    Thanks again and happy holidays,

    Lee

    Reply

  42. webster Says:

    Hello Keith

    I recently bought your script and I am thinking of purchasing the phpbay pro api script. I was told by the creator of that script a Mr Wade that I would need to subscript to maximinds geo targeting service where I will recieve a key to allow the phpbay pro api to become geo targeted. My question is can I use your script to geo target phpbay pro api script. If yes how is it done please.

    Thank you in advance for your help.

    Reply

    • Keith Lock Says:

      Hi Webster, I haven’t installed phpBay on any new sites in quite some time so I don’t know if there have been changes to it.. but the process described here used to work (probably still does) for geo-targeting phpBay. It’s pretty simple and straightforward..

      but if you’d really like to get my geo script working in conjunction with phpBay, the quickest way (maybe not the most elegant) would be to use one of the free plugins that allows PHP code to be used in posts/pages.. (this usually means that you have to turn off the visual editor, however, there’s one plugin that claims you can keep that on..but I used it and I beg to differ).. anyway… you can do it that way..

      .. my geo country WP plugin will actually make it easier because it uses shortcodes (like phpBay Pro) and you can just nest shortcodes… that’s due out soon but I have no exact time-frame as of when.. it’s ready now if you want to contact me about getting it privately, the documentation isn’t complete for it though.

      Reply

  43. webster Says:

    Hi Keith

    Thank you for your reply. I am not using wordpress as my site is a good old fashioned php/html site hence I was thinking of getting the phpbay pro api. I just wanted to know if your script would work with a standard php website (flat file) and phpbay pro api script.

    Thanks in advance.

    Reply

    • Keith Lock Says:

      oh sorry about that, i missed the ‘api’ bit.. yep.. you shouldn’t have any issues.. if something comes up get a hold me of and we’ll figure it out. thanks!

      Reply

  44. webby Says:

    Hi,

    I would like a little advice please. I thought I would ask here as it may help someone else who is trying to do what I am trying to acheive. I am not 100% great at php so sorry for asking this. What I would like to do is use your geo targeting script and block certain countries from entering my website. The code would be placed at the top of the page so it will be the first thing exacuted when someone visits my site. I have a java redirect but I just do not know the php code to use with that. What I would like to do is to list all of the countries that are accepted example “us”, “ca”, “au”, “ie” etc and the countries that are not listed would be redirected with my javascript to a site like yahoo or bing search. This would mean that if I ran a blog or forum and I was getting spam from a certain country then I could stop that spam by using your geo targeting script.

    Thanks in advance for your help.

    Reply

  45. Keith Lock Says:

    Hey webby…

    Thanks for the question ( and for the foresight of posting here to benefit others )

    I launched a new site recently so you can get the script here now: http://geotargetingscripts.com/products/geo-country-bundle/ ( it’s actually a WP plugin as well as a PHP script )

    For this scenario I would personally use the script even if you are on WordPress, although both would work fine.

    Here are instructions on how to do redirection for both WP and PHP: http://geotargetingscripts.com/faqs/how-do-i-redirect-users-from-a-different-country/

    Let me know if you have anymore questions.

    Thanks again…

    Reply

  46. webby Says:

    Thank you for the code :) I think there seams to be a little problem. If I put my country code into there like GB it redirects me to a different site. What I was wanting to do is to keep all visitor countries that are listed in the code and the ones that are not redirected to a different site. If I took GB out then I would not get redirected.

    Thanks

    Reply

  47. webby Says:

    Edit: I think I cracked it :)

    I used this code and it worked.

    Thanks

    Reply

  48. webby Says:

    Code did not appear :(

    Reply

  49. Keith Lock Says:

    @webby I’m really confused… First off, I don’t recall you buying the software.. secondly, I’m not sure what your issue is.. or if you have an issue…

    Reply

  50. Keith Lock Says:

    @webby.. that code is for the new version.. if you happen to own the old one.. the variable names are different… if you own the old one, get a hold of me through the contact form and send me the receipt and I’ll get you the access to download the new one.

    Reply

  51. webby Says:

    I did buy your software when you where selling the standard geo targeting script for $9.99 and I have managed to sort out the codes :) all is working well. I was going to post the code for the ‘old’ script but the code did not post. Thanks for the offer of the download. I will post you my receipt and order number.

    Reply

  52. Nicole Says:

    I purchased the Geo country bundle script. It works on widgets but it is not working on the actual page. I entered the same shortcode but I don’t see anything.

    Reply

  53. Nicole Says:

    Please disregard the previous comment. The problem was with Amazon links that disappear in visual view. Do you happen to know how to solve this problem?

    Reply

  54. Quads Says:

    Hey Keith,

    Having just spent 40 minutes or so reading through the questions and replies, I have one question I may have missed reading all of them, which I would like to ask.

    We are looking at targeting using a generic site with the word “local” in it, and wondered if there was any way of tightening down the amount of information which the geo tool provides, for example:

    If the user is in (town)Cheltenham (county)Goucestershire (country)UK – can we just have the town and county displayed and take away the country?

    In other words, if we wanted to do something based on “copy” like:

    “We have a vet based in (town) who covers the whole of (county)?

    Does this make sense to you? Hope so, and look forward to hearing your response.

    Oh, we are using WordPress!

    Darren

    Reply

Leave a Reply