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. Halim says:

    I still new in php editing so I want to ask if I can edit to make it ban specific ip adress? If it possible, can you show me how? Thank you for your help.

    p/s: Bookmark this page coz I want to read your reply.

  2. Christoph says:

    Hello Ozh, Answering http://planetozh.com/blog/my-projects/wordpress-plugin-who-sees-ads-control-adsense-display/?cp=70#comment-100688 I still can't get the ad rotation to work… I'm used to write…

    ad1
    **** ROTATE ****
    ad2

    but this doesn't work. I see both ads with the "**** ROTATE ****" text in between them. The same happens with…

    ad1
    *** CODE ***
    ad2

    I can't find a solution? Could it be possible that another plugin breaks the rotation?

  3. photowork says:

    Thanks for this plugin, works without problems.

  4. Geourge says:

    You didn't mention that this plugin is not compatible with WP Super Cache!

  5. George says:

    Can you PLEASE add to the documentation that this plugin is not compatible with WP Super cache? This isn't even mentioned on this page! I had to dig through comments to find it… I was wondering why "Who Sees Ads" was not respecting my rules!

    Please take a look at http://omninoggin.com/wordpress-posts/make-any-plugin-work-with-wp-super-cache/ and make it compatible using AJAX, OR please document this more clearly so people don't waste time wondering why it doesn't work.

    Thank you,

  6. Ozh says:

    George » It's been discussed dozens of times in the comments

  7. George says:

    "George » It's been discussed dozens of times in the comments"

    Yes, but it's not mentioned anywhere in the webpage nor in the readme for the plugin. I don't mean to antagonize you but it's frustrating when something so important isn't even mentioned at all. You shouldn't have to go digging in comments on a webpage to find out why a plugin isn't working as you expect it should.

  8. Ozh says:

    George » You're true. I'm just lazy. Will add the info now.

  9. mindmage says:

    thanks for the great plugin !!!!

    one question: how is it possible to tell wsa that it shouldnt show ads to people who come from the google reader ??? the referrer is somethine like google.com/reader/ and so wsa matches them to "comes from a search engine", is there any way around that behaviour?

  10. chris says:

    Rotation is broken…

    Any idea on how to fix it?

    All ads show up.

    Like Christoph above I get the text "**** ROTATION ****" or "**** CODE ****"

    This is PERFECT after this is fixed…

    Let me know.

    Thanks

  11. George says:

    Thanks Ozh, at least things are much clearer now :) I like your plugin, but I really don't want to disable caching. I would like to fork your plugin sometime and see if I can get it working with caching enabled (I think I could, using a combination of AJAX for some of the requests and client-side scripting for other checks such as search-engine traffic).

    What do you think?

  12. Piseth says:

    I don't understand it so much but trying to download and implementing it on my blog. thanks for sharing this.

  13. Ozh says:

    Calebe Aires » dude… this news has nearly 3 years.

  14. Running WSA in WordPress 2.9, and just noticed that the rotate ads code line had disappeared. Went into the WSA directory, and found that the my_options.php file had disappeared. Copied the sample options files to my computer, renamed it to my_options.php, and copied it back to the WSA directory; also modified the code text area to be 600px high. The rotate code still doesn't appear, and the code text area is unchanged. Any ideas?

  15. Rene says:

    Hi,
    i`m using your plugin with IP to Nation to show different Ads for two countries – Germany and Austria. This is working great, thanks for that!

    But i also want to show ads to Visitors from other Countries. How can i make this???
    I tried it, but it didn´t work. How can i make a ad, that is shown, if the reader is not from Germany or Austria??

    THANKS!

    Yours,
    Rene

  16. Chris says:

    I love this plugin ; However, I would like to take is visitor logged in to the next level and have it check to see if the user is an Admin or Author then no ads but, if they are just a Subscriber they would see ads or other content as i have other ides of content that i only want some groups to see but, i don't know what i need to put into the line for custom rules. It seams like it would be easy to do but, after looking online and trying a number of things I thought someone else might be able to help. Thanks

  17. CRaig says:

    Hi, I'm having problems since my recent upgrade to WP3.0 and I can't figure out why. When I update an existing ad space, I get the following error:

    Warning: Invalid argument supplied for foreach() in /home/…/wp/wp-content/plugins/ozh-who-sees-ads/wp_ozh_whoseesads_admin.php on line 1393

    The ad space seems to be failing silently — no space, no broken links, no nothing. Any ideas?

  18. Can we use your plugin to display add to a targeted visitors, if yes then how?
    Say for example I want to display an ad only for a certain area like a particular country or a particular area of a country.

    Pleas try to answer me via email.

  19. Kip says:

    Hi there,

    First I'd like to thank you for your work in making this plugin. It's one of my favourite wordpress plugins I've found over the last few years and it makes my life a lot easier!

    Drag and drop has stopped working for old contexts. That is, if you're creating a new context you can drag and drop the rules fine, but you can't edit it later on. I've tested this across 3 different blogs, each running WP3.0 and the issue has been the same across the board. Any idea what's up?

  20. Steve says:

    Having the same problems as CRaig:

    Warning: Invalid argument supplied for foreach() in /blah/html/wp-content/plugins/ozh-who-sees-ads/wp_ozh_whoseesads_admin.php on line 1393

    Using WordPress 3.0.1 and WSA 2.0.3

  21. Bill says:

    Geo ip conditions to show banner, can this plugin do this and how?

    Thanks

  22. Ozh says:

    Bill » yes & read the docs

  23. I've noticed that if a search visitor comes from the "https" version of Google, then they're not treated as if they are search visitors. Is this a bug or by design?

  24. Ozh says:

    Bhagwad Jal Park » It's a bugfeature. Already covered in the comments, easy to fix.

  25. I searched the comments Ozh, but since I'm not much of a programmer, I didn't recognize the references to enable "https" visitors.

    Sorry to sound dumb here, but could you perhaps spell it out for me?

  26. Chris Monty says:

    OK, I'm not much of a programmer. How would I use this plugin to NOT show ads to social traffic (reddit, StumbleUpon, etc)? What is the exact condition I should use for this?

    Great plugin, by the way.

  27. Eileen says:

    What if I want local readers, in my state, NOT to see adsense ads, and all others to see the ads? My first goal is to promote a brick-and-mortar business locally, but want to earn adsense money on people who cannot buy from us. Is this possible?

  28. Ozh says:

    Eileen » you have to install a geolocation plugin with very fine precision (not sure it exists) and then follow the example here to display ads.

  29. dimitri says:

    Hi, this is a great plugin, but i have a problem. How can i do for setting up a time limit rule for displaying ads.For example a visitor can watch blog post 10 minutes per day unless the ads display on blog.

  30. Ozh says:

    dimitri » you cannot enforce that kind of (very silly) rule

  31. Chris Monty says:

    Never mind. I figured out the answer to my own question. :)

  32. Chris Monty says:

    I really like this plugin and am having a lot of fun playing around with the settings.

    How would I set it to only show a certain ad, say, after 8 p.m. Eastern Standard Time? There are certain intrusive ads that I only want to show overnight, not during the work day.

    Thanks.

  33. jeff says:

    ok im wrapping my head around this. its pretty cool. right now im using oio publisher. it lets me manage ads per category. im going to see if i can't figure a way to have this plugin manage it.

  34. jeff miller says:

    ok another question.

    is there a way to set it up so

    if a visitor comes from a search engine, then display adsense code

    otherwise display xxxx ad code

  35. jeff miller says:

    ok another question

    is there a way to set up the following

    if a visitor comes from a search engine, then display adsense code

    if not, then display this ad code

  36. bigdrobek says:

    Hi,
    I would like to setup role for this plugin:
    – if the article was written by user with author role then dont display ads.
    Can you help me with this?
    Thanks,

  37. Yael Ben-Ari says:

    I am in need of rotating my ads and above you state:

    Re:

    >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:
    PLAIN TEXT
    CODE:

    > 1.

    > 2.
    *** CODE ***
    > 3.
    >
    > 4.
    > *** CODE ***
    > 5.
    >

    I couldn't find ANY instructions on how to change or even Where To Find the "my_options.php" in WordPress.

    Please help and tell me how to do this.

    Thanks

  38. Ozh says:

    Yael Ben-Ari » From this very page: "The plugin comes with an example my_options_sample.php file. Rename it my_options.php, edit it".

  39. Yael Ben-Ari says:

    Thanks for your reply.

    I'm still not sure I understand. Do I need to "Create" or "Edit" a "my_options.php" file??? (I have poked around from within WP and with my FTP program and can't find it anywhere.) If I need to "Edit" it, where do I find it? If I need to "Create" it and then upload via FTP, where do I put it in my website's pathway.

    If I need to "Create" it, is " ***Code*** " all I need in the file? And then insert the ad code where it says "ad code" within the plugin? OR do I need to put both this ***Code*** thing and the ad code together in the same my_options.php file?

    Or am I not even close?

    Sorry to be so obtuse, but I am a very non-techie person.

  40. Ozh says:

    Yael Ben-Ari » maybe you're not tech savvy enough for this plugin.

  41. jasper says:

    @Ozh, this plugin not working in WP 3.04 ?
    i remove folder (with this plugin) and install again

    in WordPress-Plugins-Ozh' Who Sees Ads
    'activate' and 'edit' not work (open blank page)

  42. omar says:

    Hi i need some help with this plugin if possible? Ive got the plugin working but cant set it up right. I dont want the plugin to display ads if they come from search engine but other wise i want them to display…..How can i do this?……Thanks in advance

  43. Ozh says:

    omar » to be honest you're doing exactly the opposite of what's recommended. Anyway, check the examples and make your way from here

  44. Jan says:

    Hi,

    I created a context named "0". Now I can't delete it. System says: "Selection deleted", but it's always there. Is it possible to delete a context manualy? Where the context is saved? I did not find it at my database. :-(

  45. Ozh says:

    Jan » It's saved in an entry in the wp_options table. It'll be hard to edit manually. Tried to rename it then delete it?

  46. gewna says:

    I deleted the entry at the database. Now it works! Thx. :-)

  47. GengWP says:

    This plugin will be great. but is the plugin cloak the url that we put on that…?

  48. Sudeep says:

    Hi Ozh. I absolutely love this plugin. Unfortunately, like some of the other guys who've posted before me, I'm getting the following error using WP 3.0.4:

    Warning: Invalid argument supplied for foreach() in /wp-content/plugins/ozh-who-sees-ads/wp_ozh_whoseesads_admin.php on line 1393

    Do you have any idea what the problem is and what I could try to do to fix it? I'm really sad to see the plugin break in 3.0.4 as I really love how flexible it is. I'd appreciate any thoughts or suggestions you might have.

    Thanks a ton for all the great work!

    Cheers,
    Sudeep

  49. dfsdfs says:

    Yay! Managed to figure it out. Ozh, you might want to add a note about this above to help fix this issue. Basically, the problem is with the new Scriptaculous/Prototype that is bundled along with WP which seems to create issues and prevents the Javascript from loading correctly. This in turn makes the context rule for an add become empty (since the field is empty and you can't drag anything into the box due to the broken JS). This in turn gives rise to the "Invalid argument" error since the argument array is empty.

    So I did some digging around and found that WP 2.3 used to come bundled with Prototype 1.5.1, and script.aculo.us 1.7.1 beta 2. So I downloaded these specific versions of prototype.js, scriptaculous.js, dragdrop.js and effects.js. I then commented out this line:

    1. //wp_enqueue_script('scriptaculous-dragdrop');

    and replaced it with:

    1. wp_enqueue_script( 'pro', 'yourURL/wp-content/plugins/ozh-who-sees-ads/js/prototype.js');
    2. wp_enqueue_script( 'scrp', 'yourURL/wp-content/plugins/ozh-who-sees-ads/js/scriptaculous.js' );  
    3. wp_enqueue_script( 'ef', 'yourURL/wp-content/plugins/ozh-who-sees-ads/js/effects.js' );  
    4. wp_enqueue_script( 'drgdr', 'yourURL/wp-content/plugins/ozh-who-sees-ads/js/dragdrop.js' );

    With this change, everything is working like the good old days :). I know that my method could be better as I shouldn't reference direct links to local files, but I'm sure someone smarter than me can fix that. Just wanted to post to let people know how to get this great plugin working with WP 3.0.4 :)

    Cheers

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.