It’s a fact: People who click on your ads are people comming from search engines, not regular readers. In order to avoid being “Smart Priced” by Google Adsense, you should definitely display ads to search engines visitors only. Here’s how to do it.
It’s a fact: People who click on your ads are people comming from search engines, not regular readers. In order to avoid being “Smart Priced” by Google Adsense, you should definitely display ads to search engines visitors only. Here’s how to do it.
First, we have to create a function. paste the code below in your theme functions.php file. Create that file if it doesn't exists.
function scratch99_fromasearchengine(){
$ref = $_SERVER['HTTP_REFERER'];
$SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}
The $SE array is where you specify search engines. You can easily ad new search engines by adding new elements to the array.
Then, paste the following code anywhere on your template where you want your adsense ads to appear. They'll be displayed only to visitors comming from search engines results.
if (function_exists('scratch99_fromasearchengine')) {
if (scratch99_fromasearchengine()) {
INSERT YOUR CODE HERE
}
}
Credits goes to Stephen Cronin for this awesome recipe!
46 Responses
That is a fantastic way to limit your adsense ads to search engine viewers. I normally would use the “Who Sees Ads” Plugin, but if this works then I will ad this to my arsenal ASAP.
I did have a quick ‘Q’ for you though. Does the code above only block Adsense to users from Google, or is it all search engines? I am not that great at interpreting code, so any help would be rad!
Note that a PHP-based solution won’t work properly if you use a caching solution, such as the WP-SuperCache plugin. Right?
As a suggestion for a future post, I’d like to see a Javascript solution to the same problem.
Thanks for the tip!
@Luciano: I have never tried this recipe on one of my online blogs, so I can’t be sure about that but you seems pretty right on that one. A javascript solution is a good idea indeed, I’ll think about it!
Interesting post! Chitika’s *Premium* ads ONLY show to US and Canadian search engine vistitors AND the targeting of the ads is based on the exact search engine query entered by the end user immediately before clicking to your site.
jeff at chitika dot com
@Luciano WP Super Cache has support for custom caching, see the Other Notes
http://wordpress.org/extend/plugins/wp-super-cache/other_notes/
Donncha includes support for his No Adverts for Friends plug-in.
(Which also covers visitors from search engines too)
Thanks for pointing it out, Lee!
I checked it and will try to implement in my blog soon.
If only there was a WP-recipes tutorial explaining it step-by-step!
@Luciano: You’re not the first to request more detailed tutorials. For the moment, WpRecipes is still young, but I should do that in a near future
Can you share your revenue increase/ decrease after doing this trick?
Also, will it show ads to reddit, digg , stumbleupon and other new users?
@Vygantas: I’d like, but I have not implemented that trick on any of my blogs. You can add digg, reddit etc to the $se variable and visitors comming from theses sites will see ads.
Wow, this is truly good and I think I have been “disliked” by Google for a while ^^ maybe this will fix our relation
Why error on my blog?
This is perfect, there is a plugin for this, but it’s useless, doesn’t work all the time, and this is just what I’ve been looking for, thank you!!
Do I need to do anything to the adsense code before I replace ‘INSERT YOUR CODE HERE’ with it? I can’t get this to work the way it’s explained here. It seems like certain characters in the AdSense code (<, etc) are breaking the page.
Thank you for your useful article.
Great tip to prevent the blog from smartpricing. I will use this hack on my site and will post the results soon.
Is there a way not to show adverts to visitors from few websites only and display to everybody else? I would love to have that code.
I would appreciate the help very much. Ready to pay too.
Thanks. Can you give us an example of the code with the search engines included in this array? I’m unclear on how to specify search engines in the $SE array. Thanks.
Im confused on the part where it say “insert code.”
Do i place the whole adsense code that generates when done choosing a channel or just the id code.
Can some one please help!
This is a very useful hack and one that I can certainly benefit from using. I much prefer the hacking solution to using a plugin.
Thanks for sharing,
Karl
I’ve put the code according to the instruction, but the whole code turn out on the top of my blog. Is there anything to add before the “function scratch99_fromasearchengine(){“
Trackbacks: