Support » Plugins » New Plugin: Ads By Country (Javascript version)

  • I’ve just written a plugin to show ads (HTML code) to site visitors (as sidebar widgets) based on which country they’re in.

    From the US? ==> You get the US ad
    From the UK? ==> You get the UK ad
    From Australia? ==> You get the AU ad

    It’s been possible to do this using “Who Sees Ads” (or WSA) except that WSA doesn’t work when you’ve got caching turned on. The WSA logic is all written in PHP.

    I had a requirement to use W3 Total Cache. So I wrote this plugin using Javascript only. It uses the (free) MaxMind GeoIP JS Web Service to return the user’s IP/Country using only Javascript.

    Anyone want to test it and/or look at my code?

    http://dl.dropbox.com/u/8595135/ads-by-country.zip

    OUTSTANDING QUESTIONS:
    I’m not a great coder, so I may be making some mistakes…

    1. There is an “Ads by Country” options page where you put in your ads (your HTML Code). That code gets saved into the WP database (wp_options table).

    2. Should I create a different entry in the DB for each country, or combine all this into one array?

    3. Should I implement some kind of simple caching? Right now, every time the user loads the page, it uses the WP “get_option” function to pull the ad code from the DB. I’m thinking each user only needs to pull that from the DB once.

    4. Does it need some error checks?

    Above all, I’m trying to reduce the impact on the server by being smart about using the DB.

Viewing 3 replies - 1 through 3 (of 3 total)
  • How can I use your plugin for putting ads by country in Template. Please tell me HTML code to put in template.

    Secondly, it works great in widget. Are you planning to include more countries. How about including India in the next update.

    3. Should I implement some kind of simple caching? Right now, every time the user loads the page, it uses the WP “get_option” function to pull the ad code from the DB. I’m thinking each user only needs to pull that from the DB once.

    No need for caching, just enable Database Debug mode in W3TC and see if the query is being cached by W3TC, then encourage users to use W3TC for best results if so.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘New Plugin: Ads By Country (Javascript version)’ is closed to new replies.