Show Adsense To Search Engine Visitors With JavaScript
Making money online via Google Adsense could sometimes backfire without warning. Some of us are already aware of Google’s smart pricing which is simply a reduction in CPC on ads shown on blogs displaying Google Adsense with a dismal CTR (click-through-rate).
To avoid this smart pricing of a thing, bloggers/webmasters have resorted to showing Adsense ads ONLY to search engine visitors as studies have shown beyond reasonable doubt that regular visitors don’t click on ads. Rather search engine visitors do.
There are plug-ins and codes to achieve this but most of them don’t work with cache plug-ins which are required to speedup wordpress blog load times. A work around using JavaScript has been developed for blogger blogs but is surprisingly valid for wordpress blogs too.
This tutorial is based on how I got Stephen Cronin’s hack/code to work on my blog with W3 Total Cache installed.
NOTE: Please backup your theme files before proceeding. I will not be responsible for any bugs in your site due to following this tutorial to the tee.
Let’s begin.
HOW TO RECOGNIZE SEARCH ENGINE VISITORS ONLY USING JAVASCRIPT
The first step in showing Google Adsense to search engine visitors only is to recognize them using a tiny piece of script which has to be placed in the header of the site/blog.
What this script does is to detect visitors coming from popular search engines such as Google, Yahoo etc and then set a cookie that marks them appropriately. This cookie is by default set to expire after 3600000 milliseconds = 3600seconds = 60 minutes meaning that after 60 minutes, visitors from search engines will quit seeing Adsense ads.
Copy and paste the code into a text file, preferably using NotePad. Change the website address in red to your own domain name and then save the file as searchengineonly.php. Upload the file to the folder of your current theme.
<script type=’text/javascript’>
//<![CDATA[
var ref = document.referrer;
var se = new Array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
var sevisitor = false;
for (var i = 0; i <= se.length-1; i++) {
if (ref.indexOf(se[i])!== -1) {
var expiry = new Date ();
expiry.setTime(expiry.getTime() + 3600000);
document.cookie = “sevisitor=1; expires=” + expiry + “; path=/; domain=strictlyonlinebiz.com“;
sevisitor = true;
}
}
//]]>
</script>
Next, you have to reference searchengineonly.php from your blog’s header.
Open header.php and right before the close of the head tag </head>, add the code below
<?php include (TEMPLATEPATH . ‘/searchengineonly.php’); ?>
This should look like this

HOW TO CHANGE ADSENSE’S CODE TO LOAD ONLY FOR SEARCH ENGINE VISITORS
Without violating Google Adsense’s policy, your Google Adsense code must take the shape below in order for Google ads to be shown ONLY to search engine visitors.
<script type=’text/javascript’>
//<![CDATA[
var results = document.cookie.match ( '(^|;) ?sevisitor=([^;]*)(;|$)’ );
if (sevisitor == true || results[2] == 1) {
var adsenseString = “<div style=\”float: left;\”>\n”;
adsenseString += “<script type=\”text/javascript\”><!–\n”;
adsenseString += “google_ad_client = \”pub-****************\”;\n”;
adsenseString += “google_ad_slot = \”**********\”;\n”;
adsenseString += “google_ad_width = 336;\n”;
adsenseString += “google_ad_height = 280;\n”;
adsenseString += “//–>\n”;
adsenseString += “<\/script>\n”;
adsenseString += “<script type=\”text/javascript\”\n”;
adsenseString += “src=\”http://pagead2.googlesyndication.com/pagead/show_ads.js\”>\n”;
adsenseString += “<\/script>\n”;
adsenseString += “<\/div>\n”;
document.write(adsenseString);
}
//]]>
</script>
Take note of the sections in red as you’d have to edit them according to what you have in your default Google Adsense code.
Once you’re done modifying the code to match your default adsense code, copy and paste it wherever you want to display ads and you’re done
.
Personally, I pasted the new adsense code into a text file and saved it as adsense.php and added it to my single.php file using the php code below
<?php include (TEMPLATEPATH . ‘/adsense.php’); ?>
That’s just about it. Feel free to leave a comment below if you’ve got any questions or suggestions.
Related Articles You May Like To Read
- Search Results
- Increase Your Adsense CTR With Section Targeting
- How To Show Related Posts In Blogger Blogs
- Search Engine Optimization Tips
- Top 4 Reasons Why Your Google Adsense Earnings Suck!
Thanks Udegbunam. I’ll have to try it out and see if eCPM improves over leaving Adsense enabled for all visitors.
They say ONLY search engine visitors click on ads. I thought it was BS until I tracked my stats via Google Analytics for a month and then noticed that 98% of my adsense clicks came from new visitors who in turn arrived from the search engines. Thus I decided to apply this hack on my blog. Hope it works for you too.
wow, that’s a cool trick. I never thought that it was possible, I was also thinking of removing adsense from my blog, since it is actually paying cents for good traffic (mostly organic). It’s sometimes impractical, particularly to blogs that have other methods implemented in monetizing their blogs (such as affiliate links, paid ads, etc). I’ll have to try this, thanks for sharing man
I loved this post.
You’re welcome. It was originally meant for blogger blogs but seems to work for wordpress blogs too
. I tried it with Wp Super Cache way back but it didn’t work but with W3 Total Cache it worked. Maybe I didn’t even configure right the first time with Wp Super Cache
.
Wow, this is a pretty sneaky way to avoid smart pricing. Looks like it should work well, but is it against Google’s TOS? I imagine they wouldn’t want us doing this.
I very much doubt it’s against their TOS as the only thing this hack does if prevent the ads from being shown to certain people. We ain’t modifying the core of the code to act strangely and increase our earnings. In fact I believe it saves them a lot of untargeted impressions. Anyway most sites are using it now
.
Nice trick. Maybe I will give it a trial.
The good of this trick is that, it will increase your CTR but reduce your impression. Before you can make anything from this, your blog/website must have a high significance on search engines
That’s basically the idea: Reduce Impressions Increase CTR
. Anyway my adsense earnings have slumped of recent from $3 a day to like $0.17 a day. I can’t be bothered any longer until search engine traffic gets a boost 
Wonderful trick, i am very sure that if i implement it i will make more money with Adsense. I hope this is not against Google Adsense terms of service.
COMMENT DELINKED FOR NOT FOLLOWING COMMENTING POLICY
It’s not against their TOS.
it is true that when
you minimize the numbers of ads on your blog you will increase the amount of
CPC?. Does it have anything to do with eCPM?
I really don’t know man. I’ve tried it before but didn’t notice any change