Mar
12

WordPress Hacks : 1 Display AdSense Ads to Search Engines Visitors Only

adsense

In this serie of articles, we’ll show you 10 new useful WordPress hacks to unleash the power of your favorite blogging engine. Each hack has an accompanying explanation, so you’ll not only unleash the power of WordPress but also understand how it works.

For this first post, i choosed to write about adsense in wordpress, and how to show adsens search only for visitors who come from Search Engines.

The problem. It’s a known fact that regular visitors don’t click on ads. Those who do click on ads are, 90% of the time, visitors coming from search engines.

Another problem is Google’s “smart pricing.” Being smart priced means that your click-through rate (CTR) is low and the money you earn per click is divided by between 2 and 10. For example, if a click would normally earn you $1.00, with smart pricing it could earn you as little as $0.10. Painful, isn’t it? Happily, this solution displays your AdSense ads to search engine visitors only, which means more clicks and a higher CTR.

The solution.

  1. Open the functions.php file in your theme.
  2. Paste the following code in it:
    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;
    }
  3. Once done, paste the following code anywhere in your template where you want your AdSense ads to appear. They’ll be displayed only to visitors coming from search engine results:
    if (function_exists('scratch99_fromasearchengine')) {
      if (scratch99_fromasearchengine()) {
        INSERT YOUR CODE HERE
      }
    }

    Code explanation. This hack starts with the creation of a function called scratch99_fromasearchengine(). This function contains a $SE array variable in which you can specify search engines. You can easily add new search engines by adding new elements to the array.

    The scratch99_fromasearchengine() then returns true if the visitor comes from one of the search engines containing the $SE array variable.





Related posts


Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!
  • paul

    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.

  • http://www.goboxy.com Go Boxy

    hi,
    Well, I already gaved examples how to include search engines in the $SE array, but you can add other if you want. as you can see, it’s include google, yahoo, … and it can works with others search engines too

  • http://loansbuzz.com Loans buzz

    is there any wordpress plugin to show adsense on to search engine visitors

  • http://www.goboxy.com Go Boxy

    Yes, there is some plugins to show ads only for visitors from search engine (especially Google), personally I suggest you to use “WhyDoWork.com AdSense Plugin for WordPress” it’s a good plugin with a lot of options and features, take sometime to learn about.
    To download the plugin : http://downloads.wordpress.org/plugin/whydowork-adsense.zip
    The home page : http://www.whydowork.com/blog/whydowork-adsense-plugin/

    cheers :)

  • http://www.goboxy.com Go Boxy

    I don’t think there is a plugin to do so, but if you follow the steps on this post, you will be able to do it by yourself, if you have any questions, or need help, I’ll be glad to help

  • http://bigsingapore.com Big Singapore Talks

    Is your code able to work in other html/php website than a wordpress blog? Hope you can give us a html/php version! Thanks!

  • Bianca Luckhardt

    This weblog appears to recieve a great deal of visitors. How do you advertise it? It gives a nice individual twist on things. I guess having something authentic or substantial to say is the most important factor.