On: 2007/06/28
Shorter URL for this page: http://ozh.in/kr

Warning: hefty explanations and documentation. On a rush? Give the demo a try. Chances are you'll understand right away what and how. Then download. Then please read here.

Current version: 2.0 for WordPress 2.5+ See below for older versions.

You most certainly have two types of visitors on your blog : some returning readers, and a majority of first time visitors. Returning readers come to your site for its content and for what you write. First time visitors, and mostly search engine visitors, come because they are looking for something particular, look at the page, and leave.

The first obvious thought that comes to mind when you want to monetize your blog is: "I'm going to put ads and banners everywhere". By doing so, you won't add any value or service to regular readers, who are not likely to click on your ads. By doing so, you'll also probably won't do justice to your finely handcrafted pixel polished WordPress theme. By not serving ads to your regular visitors, chances are you'll both lose little money and show your readers you're treating them differently.

Therefore, the second obvious thought about blog monetization is : "I wish I could display a lot of ads to those coming once never returning readers, but not bother my regular fans". Enter Who Sees Ads, the ultimate ad management plugin.

Who Sees Ads : the Ultimate Ad Management Plugin

Who Sees Ads ?

So, who sees ads ? Now it's up to you.

Who Sees Ads is an advanced ad management plugin that lets you decide who will see your ads, depending on user defined conditions. The association of an ad and these conditions is called a context: a set of circumstances you define, that will eventually display or not an ad.

For instance, you could consider the following criteria: Is the visitor a regular reader? Does this visitor come from a search engine? Is the visitor currently reading a recent post, or something really old?

Live demo

The plugin is active here, to display an ad on top of the right sidebar. Depending on the context, you could see it or not. Its display rules are:

  1. display if visitors comes from a search engine
  2. don't display if the visitor is a regular reader
  3. always display

The ad behavior is defined by the first rule that is matched. Visit the main page of my blog: as I've defined a "Regular reader" here (someone who has read at least 2 pages over the last 10 days), you're now a regular reader, hence rule #2 apply and you don't see the ad any longer. Now go to Google and click on the first result to come back here: rule #1 now applies, and you'll see the ad.

Define Contexts

Ad code + Display rules = Context

You already probably have the Ad code : it can be plain HTML (a text link, a image banner) or Javascript (your Adsense code). Let's define the display rules.

Who Sees Ads offers a very intuitive and powerful visual interface to create your context and pick display rules, in which you naturally select and order them with your mouse. The interface also offers a convenient way to duplicate, rename and delete your contexts.

Have a look and play a bit with this demo. You'll love it.

Display Rules

Possible rules

By default, you can pick or mix any of the following rules :

  • If Visitor comes from a search engine, display / don't display
  • If Visitor is a regular reader, display / don't display
  • If Post is older than XX days, display / don't display
  • If Visitor is logged in, display / don't display
  • If Date is between specified date interval, display / don't display
  • If Ad has been showed less than XX times, display / don't display
  • If This visitor has viewed this ad less than XX times, display / don't display
  • If All previous conditions fail, try another context
  • If Any condition, display / don't display

The ad behavior will be eventually decided by the first rule which is matched. For instance, if you want to display an ad only for search engine visitors, you'll pick the following :

  1. If Visitor comes from a search engine, display
  2. If Any condition, don't display

If no rule is matched, nothing displays, so the second rule in the above example is actually optional.

I made up a list of example display rules, be sure to check them.

Advanced Display Rules

Advanced custom PHP rules You can use PHP functions and make your own custom advanced display rules. Want to display something on home page only ? if (is_home()) display will be your custom display rule.

You can use PHP built-in, WordPress internal, or your own functions. Your brain is the limit.

Please note: you obviously need to know a bit of PHP in order to use the advanced display rules. By default, they are not enabled. If you want them active, edit the beginning of the script and set $wp_ozh_wsa['iknowphp'] to true. This requires your agreement on being on your own if you break your site or if ads don't show as expected.

There are two advanced custom display rules :

  • If ( condition ), display / don't display
  • If !( condition ), display / don't display

The if and if not rules are working the same, I just thought it could be more convenient in some cases to use an if not rather than an if, and this way you also have two custom rules for the price of one :)

Again, check the example display rules to get an idea of how powerful it is.

Features

Simple and Effective Ad Management

Even if you're not using Who Sees Ads to fine tune display rules, it will make your life easier. Pasting <?php wp_ozh_wsa('google-336-280') ?> in your PHP templates such as sidebar.php is a lot easier than cut and pasting 10 lines of javascript, especially if you decide later to change the javascript across multiple files.

Use it inline or in PHP templates

Create contexts and display ads either in your PHP files on within your posts and pages :

  • <?php wp_ozh_wsa('mybanner') ?> in your PHP files such as sidebar.php
  • <!--wsa:mybanner--> within posts and pages

Visual interface

If you haven't tried it already, play with the demo. It's not functional of course, but it will show you own the interface lets you visually create contexts, and easily rename, duplicate and delete ads.

Help Wizard

A togglable introductory help contains a handy wizard that will assist you, creating your two first rules. Click on the image for a screenshot of the Wizardry.
Wizard !

Posting help

Within the Post/Edit interface, you'll find a convenient drop down selection to easily insert context you will have created (if you create just one context, the select is replaced with a button)
Editor button

Google Adsense and Yahoo Publisher Compliant

Per terms of use, YPN (TOS) and Adsense (TOS) impose a maximum number of ads in a page, as follow (as of writing):

  • YPN: 3 ads per page
  • Adsense :
    • 3 ads
    • 2 search boxes
    • 3 link units
    • 3 referral units

Who Sees Ads fully complies to these restriction, and will display ads of a particular type up to the maximum number allowed.

Google Adsense and Yahoo Publisher Compliant, part 2

Per terms of use, YPN and Adsense don't allow ads on error pages such as 404 pages, and on pages that are not viewable by their system.
Who Sees Ads also complies to this policy, and ads won't be displayed on 404 error pages, and on draft posts a publisher is previewing.

Admin Clicks Safety

Admin Click Safety Admin Click Safety is an option that will prevent you from accidentally clicking on your own ads (Adsense or Yahoo Publisher), replacing them by a placeholder when viewed by the blog admin.
Regular visitors, of course, will see actual ads if applicable. Days of "oops I clicked it!" are over.

Widget support

Who Sees Ads is now supporting widgetized themes for easier ad management.

Custom Preferences Hacking

Advanced users with some PHP editing knowledge can now define a custom set of preferences or behaviors that will override Who Sees Ads' defaults. The plugin comes with an example my_options_sample.php file. Rename it my_options.php, edit it, and never lose any change you'd make when you upgrade the plugin.

3rd party plugin compatibility: Adsense Deluxe and Adsense Manager

For those who are already using Adsense Deluxe or Adsense Manager to manage your Adsense ads, you can seamlessly make the transition to Who Sees Ads and give it a try without uninstalling them. Instead of pasting the actual Adsense code when you create a context, just enter something like the following examples, depending on what plugin you're using:

  1. <!--adsense#mybanner-->
  2. adsensem_ad('mybanner')
  3. adsense_deluxe_ads('mybanner')

Please note: compatibility with these 2 plugins has been implemented to allow easy testing before adopting. I personally find Who Sees Ads much more powerful and efficient, and don't see the point of using it side by side with another ad management plugin. I will not continue support of these plugins if their code evolves and changes so that it breaks with my plugin.

Rotating Ads

You can define only 1 context and assign it as much ad code as you want. You just need to specify your custom code separator in my_options.php and you're done. Example, defining the string *** CODE *** as a separator:

  1. <img src="banner1.jpg" alt="Banner 1" />
  2. *** CODE ***
  3. <img src="banner2.jpg" alt="Banner 2" />
  4. *** CODE ***
  5. <img src="banner3.jpg" alt="Banner 3" />

Completely dynamic

The content managed by Who Sees Ads and whether it should display or not is processed dynamically on every visit for every visitor, to ensure maximum efficiency and make sure each visitor receives the treatment it deserves. The drawback of this aspect is that the plugin is not compatible with cache plugins, which generate each page once and serve the same static file to each subsequent visitors.

Download

Download the plugin :
ozh-who-sees-ads.zip
Extract and upload to your blog, preserving directory structure if any.
Note: download counter here and stats on wordpress.org may differ and reflect the number of downloads before this plugin was hosted on the plugin directory

PHP Template usage

The regular PHP call you will insert in your PHP templates is the following:

  1. <?php wp_ozh_wsa('myad'); ?>

However, you can pass an additional parameter to turn off output and have the ad code returned instead:

  1. <?php $code = wp_ozh_wsa('myad', false); ?>

By default, the plugin returns an HTML comment when no ad has to be displayed, for instance:

  1. <!-- WSA: rules for context 'myad' did not apply -->

A complete example of how to use WSA with your own functions would be something like:

  1. <?php
  2. $code = wp_ozh_wsa('myad', false);
  3. if (strpos($code,'<!-- WSA') !== false) {
  4.     // plugin returned actual code, do something with it
  5.     ...
  6. } else {
  7.     // plugin returned no code to be displayed
  8. }
  9. ?>

Examples and advanced use

The obvious usage of this plugin is to display ads with rules as :

  • Display ad when user comes from a search engine
  • Don't display ads to my regular readers
  • Display ads on old stuff, don't display on fresh posts

But you can also :

Greet your returning visitors

You can display ads, or really anything. For instance, display something only to your regular readers: a "welcome back" message, or a special offer you don't want them to miss.

Geo target !

In conjunction with my own IP to Nation plugin, you can easily target visitor from a particular country. For instance, you've always wanted to display Yahoo Publisher ads to American visitors only, as Yahoo suggestscompells? Easy, your context simply has to use the following custom if rule:
if (wp_ozh_getCountryName(0) == 'United States'), display

Check the example display rules for more ideas of usage.

Older version

Who Sees Ads is still available (yet not maintained any more) for WordPress 2.3.3 and earlier. Note that I strongly recommend always running the latest version of WordPress.
Download: Who Sees Ads 1.3.3 for WordPress 2.3.3-

Question?

If you have a question, read all the comments: the answer *is* there.

Shorter URL

Want to share or tweet this page? Please use this short URL: http://ozh.in/kr

Metastuff

This page "Who Sees Ads ? Manage your Ads, Control Who Sees Them" was posted on 28/06/2007 at 10:04 pm
Watch this discussion : Comments RSS 2.0.

826 Blablas

  1. Ozh says:

    Ben » Bots don't see ads.

  2. Hello Ozh, this looks like a great plugin but I'm struggling to get it to work. I've followed all the instructions, and have it set to show only to visitors from search engines, and only on older posts. So far, my Google ads are all clearly visible, even to me. Does this work ok with WP 2.8.4, ad if so, could you please tell me where I might be going wrong?

  3. Ozh says:

    Brenda Burrell » The plugin works fine with any version of WP.

  4. Okay that's good, thanks. But my adverts are all still displaying. Could you please advise me how to troubleshoot this issue? I've de-activated and re-activated the plugin, reset the contexts, checked and recopied Adsense code. What am I missing?

  5. Ozh says:

    Brenda Burrell » Post a screenshot of your rules somewhere. How can I help if I don't even know what you're using?

  6. I don't know – there might be know issues with first installation (it's my first time with Google Adsense too) or some other unknown variable, or who knows it could be my template doesn't like the code, or some conflict with another plugin. No idea. Here's a screenshot. Looks okay, maybe?

    http://www.thephotographypages.co.uk/rules.jpg

    The page is here:
    http://www.thephotographypages.co.uk/

    Thanks – it's an important plugin. I wouldn't use adverts without a way of not showing them to friends & regulars, so I appreciate your work on this.

  7. Okay, 16k downloads can't be wrong, but I've deactivated this. If you have any thoughts or suggestions, I'd be very glad to hear them. Many thanks for your time in any case.

  8. JFG says:

    Hi Ozh,
    This seems like a wonderful plugin. I have not been able to have it work at all. Nothing shows up no matter what I do.

    I use WP 2.8.4 with latest Atahualpa Theme. I've triple-checked the code, the context, the conditions (I've got the simplest of conditions set up : if coming from a search engine display otherwise don't). I'm not using it with any other Adsense plugin. I've tried using both the tag in the posts or the php in the template. And yes, the plugin is activated. I'm lost!

  9. What a plug in .Really cool and excellent

  10. Shelly says:

    Hey Ozh – nice little plugin you've got here. I finally have a chance to use it, and it's really nice.

    I only have 2 things to note/request.

    #1, there's a weird character in your code. I've tried to locate it for you, but I can't. But maybe when I tell you what it is, you'll know where to find it. (I only found 1 thing that was close, but I didn't see anything odd.) You know how, when people use Microsoft Word to post their stuff sometimes, you'll get that black diamond with a question mark in the middle for odd characters? I'm seeing that. Only when I "view source". Example: (I don't know if the ? thing will show, but I'll give it a shot):

    <div class="widget ?lambda_319″>

    if, after I hit submit, that fixes itself somehow, the black diamond/question mark thingy is showing up *right* before "lambda".

    #2 it would be REALLY awesome if we could give the ad a title/header for the widget. I'm using it for a site where they definitely want people to *know* it's an ad (it's a site with a LOT of images, an they don't want the ads to be mistaken for an article). Right now, I'm just adding it in the "ad code" – but it would be nice to just have a place for a title in the widget.

    #3 it would also be nice if the widget had a class that was simply "ad-widget" alongside of "ad-[$context]" I know that some people like to style their ads differently, but a lot of the ads I'm using all have the same formatting, and because the context is a part of the ad ID, that means I have to redeclare the same stuff every time I add a new advertisement in my stylesheet.

    Of course, none of this is *pertinent* – it'd just be nice :)

    Thanks for the awesomeness!

  11. Lekha says:

    Hi,

    Is there any way to include a tracker(views and clicks per ad) to this plugin?

    Thank You,

  12. Installed OZH on our BlackBerry Blog blogberry.de – everything works fine. Great job, thank you.

    Is there a version for WP 2.8.4 planned?

    Greetz,
    Sascha

  13. Ozh says:

    Sascha – Blackberry Blog » The current version is for 2.8.4 (or any current latest release)

  14. Konstantin says:

    Hello, I've been using WSA on my wpmu install for a few months now and everything is fine, but now I'd like to exclude several blogs from showing ads.

    How can this be done? How and where should I add a check for blogs? Something like if (blog_id = xxx) dont show ad?

    Thanks.

  15. Jamie says:

    I'd also like to be able to have the ability to turn ads on/off for specific sites.

    Is this possible?

    Thanks! :~S

  16. Patty says:

    Hi, I was testing the plugin and I love it. I set one of the ads for visitors from search engines only. With Chrome and IE it seems to work fine, but I just noticed that it didn't seem to work for Firefox. I deleted my history, etc. and tried again, but still, when I enter from Google, the ad unit in question is not shown.

    Firefox does show the other ads. And it also shows this particular unit when I change the settings, eg. 'If any conditioner then display'. Any thoughts on what I could do?

  17. Ozh says:

    Patty » This is not browser dependent, unless browsers have stuff regarding ads (javascript disabled, ad block plugins, etc)

  18. Patty says:

    Thanks for the quick reply, Ohz!

    I do have javascript enabled, have no ad blockers etc, because otherwise the other ads wouldn't show up, and this particular ad unit then also wouldn't show up when I changed the rules. But it did.

    The only rule I use for that ad is 'If visitor comes from SE then display'.

    I'm very curious though. Would you (or anyone) mind trying it with FF and IE and see if there is a difference? <a href="http://www.google.nl/search?hl=nl&q=http://www.spiritueelmagazine.nl/be/geluk/&btnG=Zoeken&meta=&aq=f&oq=&quot;. The ad that should show up is placed below the bread crumb and above the title.

    Would very much appreciate it :)

  19. Patty says:

    Sorry for the screwed up code. But you what's even weirder, when I enter the link of the previous post and then enter through Google, it does show! But when I enter random keywords for that page (in Google.nl for my country), like 'spiritueel magazine geluk dirk', and then enter the page, it doesn't show…!

    I also edited the settings for the bottom ad unit, see if perhaps I did something wrong with the top one with the placement. But same thing!

    Maybe my FF is just weird…?

  20. Patty,

    Your top ad shows up when arriving via search via Firefox. I just tested it for you. The bottom ad shows up no matter what, but I don't know what rules you have set for it.

    Something is wrong with your Firefox. I would suggest setting up either another profile or another user on your machine if you want to test with Firefox.

    RT

  21. Patty says:

    Thanks! Still find it strange that my Firefox is weird like that, but I'm happy to hear it's just me. Most of my income comes from random visitors who don't really intend on visiting my site, and 20% of visitors use Firefox. So otherwise I'd really miss out.

  22. peterg says:

    Is it possible to build a rule based on an IP-filter, e.g. Dont't display if IP starts with XXX.YYY.?

    thanx in advance

    Peter

  23. Ozh says:

    peterg » of course you can. Use an advanced filtering rule with something like if( strpos($_SERVER['REMOTE_ADDR'], 'xxx.yyy.') === 0 ) then don't display.

  24. Elliott says:

    I simply love this plugin, however is there a way to easily add pages to show for the search engines? I get a lot of traffic from some different sites that I would like to test and see how it converts. I have tried hacking the code to add it, but it would be nice to have an option field to be able to add a site to show just like the search engines.

    Thanks a ton!

    ps: I looked around at the comments and couldn't find any help with this, maybe I just missed it.

  25. Ozh says:

    Elliott » there's a self explanatory variable in the custom config file my_options.php

  26. Elliott says:

    Thanks for the quick reply.

    If I update the plugin from my original upload, does that overwrite it and require remodification in anyway, or do the changes I set in place remain?

  27. Lisa says:

    Okay, I think I did it, but how will I know. What if I want to edit it? Where is the ad?

  28. Fernando says:

    Hello,

    I have the rule if visitor comes from search engine -> display

    It seems that it only works during a certain interval of the day.

    Do you also have this problem?

    I have WP super cache enabled with 1800 as expire time, but I clear the cache to do the test.

  29. SantaCruze says:

    Heya there,

    Iam using also the plugin, it works great but…i thought it would change the adsense income thru a higher ecpm but it doesnt actually =( Maybe u could insert a new option for not displaying ads on a special site?

  30. Beo says:

    Thank for good plugin.

    Can you increase function to check spider from search engine. My idea is need to block some script from spider.

    Thank you again.

  31. Abbas says:

    I don't know if this has been asked or answered before..

    Can I exclude ads on a page by specifying a URL?

    for example… http://xyz.com/noads.html

  32. Holger says:

    Hi,
    I have installed you plugin. I want to display Ads just for Search engine visitors. But it seems this feature isnt working for me. All other rules work exept the search eingine visitors feature.

    I use WordPress 2.9.2. (German from http://wordpress-deutschland.org/download/) and WSA 2.0.2 downloadet yesterday. I set up a rule with

    if visitor comes from search engine then display

    and I tried

    if visitor comes from search engine then display
    if any conditions then dont display

    went to google, searched for a phrase my site is ranking for, click on the link to visit my site but with both rules no ad is showing up. :(

    There are many features in the plugin I like, but the search engine one is the most important I was looking for. Can you please help me get this work? You can contact me by eMail or respond the comment.
    Thanks

  33. Holger says:

    Update: I just checked it through yahoo. If I visit my site through yahoo serps it works. Visiting through google serps it isnt working. Any Idea?!

  34. Try it with a different browser. It sounds like a browser caching issue to me.

  35. fernando says:

    Holger, I have the same problem. You can even remove the second rule. Just keep

    if visitor comes from search engine then display

    If none of the rules apply, then no ad is displayed.

    It works sometimes, but not always… :(

  36. Syed Abbas says:

    Hi,

    I have been using this plugin for a while and I love what it does.

    I am having problem with setting a condition to remove ads from a particular Url. Has anyone tried to do this before? Plz help.

  37. Holger says:

    @RT Cunningham

    I checked in Firefox 3.6 and IE 6
    Firefox no ads show up, IE works. Hmm.. But its strange it works in Firefox for yahoo visitors, isnt it?

    @fernando

    thanks for reply, I thought I am the only one with this Problem. But this are no good news. The Idea of the plugin is genius but if it do not work for all visitors the same? Hmm.. I cannot belive this. I read lots of blogs hypeing the plugin for this feature.

    Why should it work for some browsers/visitors and for some it do not work?! Isnt the modul only analysing the referrer of visitors? Isnt this independent of which browser visitors use?

    I never read of this problem with the plugin. Would be nice to get some feedback from the Admin. Thanks.

  38. Holger says:

    @RT Cunningham

    btw. I have cleared the browser cache and tried again with firefox on google serps. dont work also. so I think it is no caching prob.

  39. Holger says:

    I think I got the problem. I have set my google Serps to show up 100 results in a single page instead of 10. If I switch to 10 results per page, do a google search and click on my site everything works well and the ads show up! This explain why it is working for other browsers (where no cookie for the 100 Results per page is set).

    @fernando
    Can you confirm that? Are you using more then 10 results per page in google too?

    Perhaps this can be fixed in a future release. For shure there are not many Users which have set more then 10 results per google Serps page, but there are some.

  40. fernando says:

    Holger, I am using 10 results per page.

    My advice, turn on the ads for everything…

  41. Holger says:

    This would be a solution but it looks like it is working for me except the described situation. I will check the size of search engine visitors and compare to the ad impressions. If there will not be a major difference I will go with the plugin. I like the features of the plugin and dont want to bother my regular readers with ads, thats why I have installed who sees ads.

  42. Ozh says:

    To all subscribed to comments here: I've updated the plugin with a little change that will take care of the google visitors.

  43. Christoph says:

    The lastest Update to 2.0.3 broke the ability to rotate ads. "**** ROTATE ****" like before or "*** CODE ***" doesn't rotate the ad.

  44. Ozh says:

    Christoph » no it didn't change it. But it probably overwrote your custom setting file.

  45. ADW says:

    Is there a changelog for this plugin? I've yet to locate it if there is one.

  46. fernando says:

    Ozh, I did not get a notification in my plugin list for who sees ads? Is that normal?

  47. agentc0re says:

    @ozh Howdy again. I just noticed that adsense link-ads are not being counted differently from text/image ad's. I found this out because i have a long link-ad banner in the loop. Home page only shows it once. Along in the home page i have two image/text ad's and a text only banner.

    When i click on another category, the max link-ad's will be displayed. I was fiddling around trying to figure out how you detect a link-ad over a text/image ad but couldn't find it. Anyhoot, let me know if you need any experimenting done.

  48. agentc0re says:

    @Ozh Ah ha! I figured it out. Your method checks for an older (and unused by google in more current created ads) that defined an add by it's type with a variable.

    I'm wondering if it might be better to maybe add the option of specifying if his is a link, text, image.. etc. etc. type of ad and checking against it within your own variables. What do you think?

  49. NavaPavan says:

    Such a nice plugin. Thanks for sharing.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.