Friends don't let friends see adverts

This post has been a long time in the writing. Ever since I started advertising on my blogs my strategies have been tweaked continuously so consider this post a snapshot description of what I’m doing with Adsense advertising now. This is a long post, but read through it. The plugin I use to do most of this stuff is linked near the end.

Last year at the IT@Cork Web 2.0 conference, Gavin mentioned that he earns enough off his blogs to pay for his hosting, and I thought to myself that it would be handy to have an extra bit of cash to do likewise. I didn’t do anything about it until July when I signed up for an Adsense account and put some ads on the site. Things were slow that month but they’ve steadily improved to the point that it’s a reasonable second income now.

At last year’s WordCamp in San Francisco, one of the talks was about monetizing your blog. It was a fascinating talk with a great discussion afterwards and I brought home some good ideas:

  • Don’t show adverts to your friends. They are the people who visit your blog and leave comments. They’re not going to click the ads anyway.
  • Position matters. Right underneath the post title and above the content is the best place on a blog to put an advert. (Thanks Matt!)
  • Go as wide as you can.
  • Experiment with ad colours, borders and sizes. Don’t accept the Google defaults. Blend your ads or make them stick out. It all depends on your blog.

Since then I’ve developed my ad serving strategies further:

  • I love when people comment, and I’m honoured when people subscribe to my blog. Therefore I won’t show my RSS or email readers adverts. If you like what I do enough to subscribe I won’t burden you with advertising. You’re my friend.
  • Don’t show adverts on the homepage.
  • Adsense Injection is great for putting adverts directly into posts.
  • Monetize your archive. Any post older than a month gets adverts.
  • Don’t show adverts to Digg, Delicious and Stumbleupon visitors.
  • Identify where most of your “just passing through” traffic is coming from and show them adverts, except for social bookmarking websites of course.
  • If my blog showed you adverts, I’ll tell you “Don’t like adverts? Leave a comment and they disappear.” below the comments form. At least one person has commented favourably about that.
  • Fill the competitive ad filter with low paying URLs. If you’re still showing ads from then you’re missing out. If your daily eCPM isn’t at least $5 you’re not making the most of your advertising. Subscribe to to see which MFA and low paying sites go into my competitive ad filter. I’ll talk about the competitive ad filter in more detail in a future post.
  • Set an hour long cookie for users from search engines. Blogs have a notoriously low attention span for most visitors but if they click to the front page, show them a few more ads.
  • I use Kontera too but the returns from that have been very disappointing. One of my posts has an AuctionAds unit in it. You’ll see that no matter what because I’m testing it for a few weeks and the post in question is almost always only hit by visitors from Google.

I run advertising on my photoblog, In Photos dot org too but the rules there are a bit different:

  • Each post has a big image, pushing the text description below the fold. That’s not ideal for displaying adverts so I use the left sidebar to show a 600px high Adsense skyscraper unit.
  • Show the sidebar advert even on the homepage. It’s not an ideal location so better give it as much exposure as possible.
  • It’s difficult to attract visitors to a photoblog. I wrote 11 seo tips for your photoblog to outline some of the ways I draw traffic in. The biggest mistake is definitely not writing about your photography. If there is no text, how can the search engines figure out what your blog is about?

I’m not the only one only showing adverts to selective visitors. Recently Ben Gillbanks had a great post on increasing Adsense earnings that says some of the same things I summarised here.

I haven’t tried it yet, but the who sees ads plugin from Ozh does most of the same checks I do. That plugin won the WordPress plugin competition so congratulations to Ozh on winning!

The No Adverts for Friends plugin

Announcing my shiny new, rough as anything No Adverts for Friends plugin! This plugin adds new commands that you can use in your templates. Use them to surround your Google Adsense or other advertising code.

The No Adverts for Friends API:

  • is_regular_user() – returns true if the visitor has left a comment or is logged into your blog.
  • is_whitelisted_site( $url ) – returns true if $url is in a pre-defined list of friend sites like Digg, Delicious and StumbleUpon.
  • is_old_post() – returns true if the current post is over a month old.
  • is_searchengine_user() – if a user comes from one of the listed search engines or this is an old post return true.

Each of the API calls depends on the one before it returning a favourable value. For example, is_old_post() won’t return true if is_regular_user() returned true, no matter how old the post is.

Example usage:
<?php if( is_searchengine_user() == false ) { echo "Google adsense code goes here"; }?>
Edit single.php in your current theme and add that code somewhere within the loop. Now either visit an old page on your blog or use a Google search query to bring you to your blog. Hopefully you’ll see the text “Google adsense code goes here”. Replace this text with the Google Adsense Javascript.



  1. Rename both files to .php and place friendsadverts.php in your plugins folder. If you use WP-Cache copy wp-cache-phase1.php into plugins/wp-cache/ overwriting the file already there (make a backup first!)
  2. If you use WP-Cache copy the $nevershowads and $passingthrough arrays from friendsadverts.php into your wp-config.php. They’re needed by WP-Cache which kicks in well before plugins are loaded.
  3. Activate the “No Adverts for Friends” plugin from your plugins page and modify your templates using the new API.

Well, you’ve read this far. If some of the advice in this post helps you, if you like this plugin, if it improves the user experience of your regular visitors and maybe even increases your advertising revenue please consider uncommenting the add_action() command at the start of friendsadverts.php. The donnchas_happy_happy_notice() function prints a message in your blog’s footer saying you use this plugin and links back here.

Thanks John for bugging me to write this up. Hopefully I’ll see you at next year’s WordCamp!

88 thoughts on “Friends don't let friends see adverts

  1. I think it should be mentioned that you should try your design with a powerful ad blocker and make sure it still works. The only thing worse than a lot of advertising is finding the whole place a mess because the design uses the ads widths and heights without hardcoding them and everything breaks when they’re taken out.

    I wonder why the suggestion of not showing ads to social sites. Considering the stupidly high attrition level of these (over 90%, IIRC) wouldn’t it be a good idea to have some adverts there? At least one from adSense, which may be relevant to what the user is looking for.

    It’s also a good thing to revisit the decisions you make, as changes in your statistics may affect them. If you start getting more attention you may want to take some of the ads away, as the others may be reporting enough to make the whole thing worth it.

    Lastly: There is one kind of publicity nobody ever addresses and I think it’s high time someone did. Old-fashioned, traditional paid publicity (like The Deck’s, probably). Where a sponsor pays to have their ads put somewhere in your page. This is a place where some education is sorely needed (sponsors tend to really like flashing, moving ads) and they don’t understand about ad blockers because they don’t care about clickthrough anyway.

  2. eduo – the users who come from social bookmarking sites are generally web savvy and they’re more valuable as prospective diggers or stumblers who will make a particular post more prominent on their sites.
    As well as that, they may blog the post too, adding lovely page rank to the url.

    Anyway, I’ve never had a post appear anywhere near the front page on Digg or any other site so this is all theoretical and repeating what I’ve read elsewhere!

  3. I like this idea, but my AdSense income is not big enough to warrant going through this type of trouble — yet. I think this is great to show more intrusive big box ads to non-friends.

    Also, perhaps there is a happy medium where I can show less intrusive ads to friends and more intrusive ads to non-friends.

  4. Pinyo: There is another very important rule: If you’re not getting much from your advertising consider taking it out completely until you build up some user mass.

  5. Donncha: That’s a valid point. I was looking at it from the other end. A huge amount of “social visitors” leave without a second glance (usually crapping on your server on the way out 🙂 but you are right, they might link back to you and those 1% are worth not showing ads to the whole.

  6. Carson – you won’t see any adverts now at all because you’ve commented, but you wouldn’t have seen any Adsense adverts on this post because it’s a brand new post.

    Delete the cookies in your browser and visit one of my old posts and you’ll see lots of adverts!

  7. I’m sure there are some great ideas in this post, but I have no idea because I couldn’t read it.

    Dark grey text on a royal blue background? What the…? Am I missing something? Are my browsers rendering funny? (I tried two.)

    Really hard to read.

  8. Matt – that’s weird, the blue should only show in the border. The rest is a white background. You could always subscribe, then you’ll be able to read it fine! 🙂

  9. Hello, Can you give me more Example usages?
    Only search engine users and first visit users should become google ads. It’s your plugin compatible with adsense manager?

  10. This is quite possibly the worst advice I have ever heard about advertising and I’ve been blogging for over five years. Way to get it linked from the WordPress dashboard though.

  11. Donncha – Hm. I beginning to wonder if it’s a Mac browsers issue. I ran across another WordPress theme with the same problem. That guy worked some CSS mojo and fixed it. (Dunno what he did–I lack CSS mojo.)

    What’s even weirder is it looks fine now. I didn’t change anything–didn’t flush caches or anything. Just came back to check comments (which looked fine before) and everything looks fine. Nice and readable. Go figure.

    And I was right: There are some great ideas in there (which I can really use, being new to blogging).

    “You could always subscribe, then you’ll be able to read it fine!”
    Why, I believe I will.

  12. Mattt (sorry, I forgot the last t in my first reply!) – stranger and stranger. I’m just glad my blog displays fine for you now. I’ve viewed this blog in Safari and Firefox on the Mac and haven’t seen the problem you saw. The mind boggles! Thanks for subscribing, hope you enjoy everything else!

    Freetagger – I’m not sure about adsense manager but I’m sure if you knew your way around the code you could add my commands in the right places to make it behave. I’ll add more examples tomorrow when I have more time.

    James – that is quite possibly the worst critique of a post I’ve read and I’ve been blogging for 10 years! 😉

  13. Donncha: I do not see any ads on this page! That is before writing this comment! And trust me, this is my first visit to your blog! Not that I really want to see ads, but I am concerned if the plugin may work counter productive!

  14. Vikas – that’s fine, you weren’t going to click an advert anyway were you?

    As I said before, the post is too new to show adverts. Wait until it’s a month old, then you’ll see ads plastered all over it if you remove your cookie. 🙂

  15. I’ve been trying to weigh the ups and downs of increased revenue (read: actually making enough to cover my hosting) from adding more ads to my site against angering my few hundred regular readers and I think this simple plugin just gave me my solution.

    This is a wonderful plugin, thanks!

  16. Personally, I don’t mind seeing ads. Adsense ads don’t bother me too much (although I usually don’t click on them) and banner ads are fine as long as they’re quiet and don’t follow me around the screen.

    What I can’t stand, however, are those damned context links, the ones that underline a word and have the js popup. I usually avoid sites that do that.

    Another type of site I avoid are those that have the paid posts. “This post is sponsored by….” If a blogger has to resort to that tactic, then what makes anything they write about worth my time?

    Personally on my site I have Adsense on some older posts (added by hand when I get around to it.) I’ve only made a few dollars, but I only have a dozen or so on site.

    Since I write a lot about TV shows, I put Amazon links on my site, and it’s really my only source of revenue. But since it’s related to what people are comming to my site to read about, it can also be effective.

    And it’s not in-you-face.

    As for ads in feeds, I find that crass. Like you said, they’re ‘friends’ or regular readers. They deserve better.

  17. Only search engine users and first visit users should become google ads, can you please created the code for me? I cant php, and when I use your Example, become only search engine visitors ads, but first visitor should always become ads to see.
    I hope you unterstand my grap english.

  18. Freetagger: instead of using the “is_searchengineuser()” command, replace it with “is_regular_user()” and it will show adverts to anyone who hasn’t left a comment on your blog.

    My functions don’t support showing ads to first time visitors but the above should do.

  19. Thanks for this. I’ve been wrestling with what to do about ads for a year now — and I’ve left them off because of not wanting to inflict them on my regular readers and actual friends.

    This leads me to reconsider my no ads (and consequently, no advertising income) stance.

    Much appreciated. I’ll spread the word.

  20. I don’t run ads on my personal blog (not enough traffic to really bother), but I do run ads on an extremely popular site I run. With a server bill of over $100 month, I’ve been forced to (plus it’s nice to have a little extra cash in my pocket).

    However, I did my very best to while put them where easily seen, not make them stick out like a sore thumb.

    I also don’t put ads on the site’s forums for registered users, just for guests along with a message along the lines “Don’t like ads? Register for a free account”.

    There’s a fine line to walk between plastering your site (I could probably do better money wise, but at the cost of annoying my users) and just making a tidy income.

  21. Ozh – I’ve been meaning to, but time is the killer..

    Rico – Ah yes, that was a great article. I read that months after it was written and it certainly gave me confidence that I was doing the right thing!

  22. Great Plugin. I’m searching for that kind of plugin and thanks I found It. Yeah, your friends or our friends will not click the ads but to read, get an ideas and information and leave comments to our blog. They are a publisher jut like you.

  23. I’ve been dugg 7 times and on slashdot 3 times and I agree with your findings.

    The CTR drops through the floor when you get traffic from these sources, it’s not worth showing them ads as they will

    1) Complain about it
    2) Ignore the article (especially if you have ads IN the content)
    3) Leave quickly
    4) PROFIT!

    Anyway, better to retain some of them as RSS subscribers and repeat readers than show them ads and earn a few extra bucks.

    You gain more in the long term.

    Another thing you might consider adding is a switch to change the block, I put smaller ads in recent posts rather than none…and then switch them out to large rectangles when they are a month or so old (the highest CTR unit).

    Good work anyway 🙂

  24. Why do the functions rely on each other? If I have a function to test whether a post is old — is_old_post() — the only thing I’d want it to return is true if the post is old or false if the post is new. Whether or not a user is a regular user should have no bearing on whether a post ir old or not.

    This way, I can create the combinations I want in the code without having to worry about dependencies.

  25. Flexo – that’s just the way it works, but you’re free to modify the code.

    Originally I did have the functionality separate but I found I was doing all the same checks all the time so I made the hierarchy of functionality that exists there now.

  26. Hello there,

    I can’t see your blog either. Its all blue and sometimes a white field (mostly replies from Donncha). Or is this really only for friends?

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.