How to Reduce AdSense Impressions while Improving the Click-Through Rate (CTR)
Before I tell you how to reduce AdSense impressions while improving the click-through rate (CTR) at the same time, I have to admit I dropped the ball on this one. Back in July, I published "Reducing AdSense Impressions from Robots", and then later inserted an update message saying I wasn't doing it that way. I meant to do a follow-up after testing, but I got sidetracked by real-world events.
These techniques require you to insert code which will set a condition. A condition of 0 will allow an AdSense block to be displayed while a condition of 1 will prevent it.
Blog Software Loops
The WordPress platform uses a loop to display posts and I'm sure other platforms do too. Any conditional code should be used before the loop starts. Unfortunately, in some cases it can't be helped. Categories and tags have to be retrieved from within the loop for WordPress.
The first two batches of code can be used before the loop.
The MSN/Live Robots
Certain MSN/Live Robots are operating with JavaScript enabled and are therefore causing needless AdSense impressions. It won't do you any good to try to block the log entries or block the robots, but you want to prevent them from causing the unnecessary impressions. This will create the prevention condition:
$skipadsense = 0;
$searchref = $_SERVER['HTTP_REFERER'];
$live = array('FORM=LVSP', 'FORM=LIVSOP', 'FORM=QBHP', );
foreach ($live as $livesearch) {
if (stripos($searchref, $livesearch)) {
$skipadsense = 1;
break;
}
}
Search Terms
Those of us with experience know that bloggers and other types of visitors will never click on AdSense ads. If they're searching for something that you know won't result in a click, you want to set a prevention condition. You may laugh, but this applies to niche sites as well.
This is the code I use for the terms I've spotted. I've repeated the first line from the previous code block for the sake of completeness:
$skipadsense = 0;
$referer = $_SERVER['HTTP_REFERER'];
$noads = array('site:www.untwistedvortex.com', 'site:untwistedvortex.com', 'powered-by-wordpress', 'leave-a-comment', 'commentluv', 'keywordluv', 'dofollow', 'do-follow', 'nofollow', 'no-follow', 'blog',);
foreach ($noads as $noad) {
$pos = stripos($referer,$noad);
if ($pos !== false) {
$skipadsense = 1;
break;
}
}
The Categories and Tags Arrays
You can set this up either before or right after the loop the starts (if you have a loop). In WordPress, the loop starts with something like "if (have_posts()) : while (have_posts()) : the_post();. You can combine two arrays into one, if the categories and tags are unique enough. I suggest using the slugs for the categories and tags instead of the names in case you edit the names later. This is a sample:
// categories:
$noads1 = array('blogging', 'blog-reviews', 'website-reviews',);
// tags:
$noads2 = array('reviews', 'seo', 'wordpress',);
The Categories and Tags Code
In WordPress, these must come after the loop:
foreach (get_the_category() as $category) {
if (in_array($category->category_nicename,$noads1)) $skipadsense = 1;
}
$posttags = get_the_tags(); if ($posttags) {
foreach($posttags as $tag) {
if (in_array($tag->slug,$noads2)) $skipadsense = 1;
}
}
The reason you have to check for post tags and not categories is because WordPress requires at least one category (such as "Uncategorized") while it doesn't require any tags.
If you have a post that doesn't fall within a particular category, but it shouldn't show AdSense, you can either use an existing tag or you can create your own to insert. I use "noads" for that purpose, just in case I forgot to include a particular category or tag.
Before and After the AdSense Code or Plugin Function
Whether you put the raw AdSense block on your page, calling a plugin or within a plugin, the principle is the same. I call a plugin. Anyway, if you get a condition of 1 out of any of the above code, this code will prevent the AdSense block from appearing.
if (!$skipadsense) {
<!–insert adsense block or plugin code–>
}
Finishing Up
Remember to watch your PHP opening and closing tags and everything should work fine. You can use it on standard template pages that show posts (i.e. "index.php", "page.php", "archive.php", etc.), but you can't use it on template pages called unless you have AdSense blocks on those pages (i.e. "header.php", "sidebar.php", "footer.php", etc.). If you use Blogger, you may want to read a different article to learn how to control who gets ads.
After I inserted this code on my "single.php" template page, my CTR doubled virtually overnight.
Disclaimer: Your mileage may vary. Slippery when wet. Objects are closer than they appear. If there are any errors in the documentation, blame someone else.
Similar Posts:
- When Google AdSense Just Doesn't Pay Enough
- Use the Google AdSense Allowed Sites Publisher Whitelist
- Blog Tip: Don't Display Google AdSense Within Sponsored Posts On Your WordPress Blog
- Reducing AdSense Impressions from Robots
- Blog Tip: Comply With Google AdSense Restrictions On Your WordPress Index Page



So do I write a whole new PHP file or just insert them it pages I have adsense? I'm still confused on where I put the code too.
My latest blog post: Unusual Place of the Month: The Mars Restaurant
Just insert where you have your AdSense, Matt.
Nice one RT. I just installed the Who Sees Ads by Ozh in my iPhone blog and this even takes it a step further blocking MSN and other robots creating impressions. I will have to make it a habit to analyze the search terms and exclude some of the useless ones too. Stumbled.
My latest blog post: Win a Free iPhone
Great tips RT!
Even though I don't use AdSense I consider it to be a MUST for most bloggers. The only exception would be a blog used for credibility building and product marketing in my opinion.
Problem is – many fail to use AdSense to full capacity!
My latest blog post: Banish Low Balling Ads To Earn More With Your Blog
Great piece. I hate getting all these impressions with no ctr !
My latest blog post: Popular green products
Bravo. I was going to ask you about this…
My latest blog post: boy monks
I had to make some corrections, so double-check the code. Sorry.
But it was only the last group. Remove the == 0
You should think about putting this into a wordpress plug-in. People would be snatching it up like hot cakes.
*Mmmmm cake~~~~*
My latest blog post: National Do Not Call List Canada
Probably, but I tried doing a plugin once. It's not my bag.
Ah, that's too bad. Since a lot of us aren't PHP geeks. I wish I was, but…
I'll have to bookmark this and give it a show sometime when I get the chance.
Thanks!
My latest blog post: National Do Not Call List Canada
I may try it. But I don't know the hooks and options pages in the admin give me the willies. One mistake and I can hose up the database. Maybe I'll take a look at "fun with plugins" (damn, can't remember the URL).
We need to find someone to make this a plug-in, I'm afraid to screw with this kind of stuff too
Much easier to press "activate" in my plug-in panel!
My latest blog post: For the Love of Wordpress
I like the idea of a plugin, but it would be difficult to make it work without hooking in twice;once before the loop and once after the loop before the content. Basically, we're looking to set a condition of 1 for $skipadsense to be present at all times so that something like "if (!$skipadsense) wp_ozh_wsa("post-top");" would work on the theme page or the condition could be checked for from within a plugin itself.
Hi RT,
This is without a doubt, the most complete solution for optimising the display of Adsense ads. You are really targeting them with a fine degree of accuracy. Congratulations!
I'm sure this could be made into a plugin, but the real problem with that is the amount of choice for actually displaying the ads (not working out whether to show them). Does it need to do everything that Who Sees Ads does as well? Or everything that Shylock Adsense does? That's really the complex bit.
My latest blog post: Setting Cookies In WordPress – Trap For Beginners
I wouldn't even want to try to get into what those plugins do. Anyway, I needed a solution and I wrote one. It works for me, and could work with anyone willing to put their fingers in, but that's not even half the bloggers that use AdSense.
Adsense is always a struggle to get the right CTR. I even find that when I am working on one of my adsense blogs I even effect my Adsense CTR. I agree that this kind of technical stuff scares the hell out of me. Maybe someone at the Academy could figure out a plug-in for this. Or maybe you could explain further on how to implent these codes and where exactly to put them. They look like Greek to me!
My latest blog post: The Affiliate Academy Teaches How to Make Money Online
Unfortunately, there isn't any way for me to explain it any better right now. Perhaps I'll contact someone who could add this to his plugin (or tell me how). I can't make any promises right now though.
Getting the highest ppc with google adsense is not easy but this article really shows that with simple code it is possible to optimize earnings. I love this article, keep up the hard work.
Oops! Go for clear content. Are you writing for new PHP files.
I'm not sure I understand the question Fergus.
I'm confused already. Let me read it again
My latest blog post: How to find dofollow blogs
I have been finding ways to do this and this is exactly what I want. Though I'm not an IT savvy guy, I believe I can apply this trick. Thank you for mentioning it. I'm going to gain a lot of benefits from using this.
Cheers!
My latest blog post: Mencari Kerja Dan Jawatan Kosong Tapi Buat Duit Dengan Mymode
Thanks, I haven't really understand it but I'll try to implement it first.
My latest blog post: How to Return to Financial Solvency Using Debt Consolidation
It never occurred to me to further filter adsense from searchers like that but it makes total sense. Damn I have some work to do…
doesnt make sense to me…dont know how this works?
My latest blog post: Make Adsense Smarter And More Relavant
Nice code. Alot simple than most i have seen. Like the fact you even do not show ads to msn bot.
My latest blog post: los angeles cheap dsl.
I have been finding ways to do this. My blog CTR rate is very is very low. Ultimately what I earn from Adsense is a penny. I will try this out.
Wow a healthy information I read here. Thanks for very informative solution regarding to Reduce AdSense Impressions.
My latest blog post: Capiznon Bloggers Whew! I'm tired
Oh.! It is very nice article. I have been finding ways to do this and this is exactly what I want. I am not IT woman, so It is hard to understand knowledge in adsense. thanks a lot
Great tip for giving a more accurate CTR. I am not real savy with coding, so I may need to get some help with this!
I use Adsense and I'm glad I found this article. Well written!
Great article. My Adsense CTR is extremely low. It took me 1 year to receive first adsense cheque for $100. I will check out your tips.
wow great amount of information, thank you for all of that, will help me in setting up my adsense campaigns
My latest blog post: Five Simple Tips To get Your Ex Boyfriend Back
At the rate I am going, it will be many months before I get paid out my first Adsense $100. I need to improve my Adsense CTR and your article has inspired me to try to do something about this – thank you for this great information.
this is a lot of good information, but it begs the question, what do you use the more accurate CTR figure for?