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 Articles:
- Updated: FeedBurner Plain Text Count for Single or Multiple Feeds
- 3 Plugins to Promote your Facebook Page
- Mint: My Favorite Analytics Program
- How to Kill Website Spambots Dead
- Putting My Money Where My Mouth Is — Sort Of
This article is published as: How to Reduce AdSense Impressions while Improving the Click-Through Rate (CTR)
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?
Was very useful and i am in the process of setting up adsense for my site so this will help me a lot
i would prefer Infolinks over Kontera because they pay much better.;'-
That's what I use now. Infolinks is definitely better.