January 4, 2010

TEXT SIZE minus plus

Show Adsense Only to Search Engine Visitors

Advertisement
You Might Be Interested In Our Popular Article
  • Most Essential Free Softwares After Windows Installation
  • As we all know that regular visitors don’t click on ads, around 90% folks who click on ads are coming from search engines.

    Also for fact that Google pays more if your click-through rate (CTR) is higher, 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.


    For WordPress Users:

    Note: Do take backup of your theme before you try this.

    01. Go to Appearance => Editor.
    editor

    02. Then choose functions.php file from right hand side and add below code:
    functions.php

    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;
    }


    03. Now, paste this code anywhere in your theme, where you want to display your adsense and they will appear only if the visitors are coming from search engines.

    if (function_exists(‘scratch99_fromasearchengine’)) {
    if (scratch99_fromasearchengine()) {
    INSERT YOUR CODE HERE
    }
    }

    04. Save the files and you are done.


    For Blogger Users:

    Note: Do take backup of your template before you try this. Only try this if you are familiar with blogger codes.

    01. Go to Layout => Edit HTML, click on Expand Widget Templates and before </head> add Below code in to it:

    blogger-head

    <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=scratch99.com";
    sevisitor = true;
    }
    }
    //]]>
    </script>
    Note: In the document.cookie line, you must change scratch99.com to your own domain!

    02. Now put below codes where you want your ads to be displayed:

    var results = document.cookie.match ( ‘(^|;) ?sevisitor=([^;]*)(;|$)’ );
    if (sevisitor == true || results[2] == 1) {


    <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-xxxxxxxxxxxxxxxx\";\n";
    adsenseString += "google_ad_host = \"pub-xxxxxxxxxxxxxxxx\";\n";
    adsenseString += "google_ad_slot = \"xxxxxxxxxx\";\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>
    Note: You’ll have to replace the xxxx’s with the appropriate numbers from your Adsense code and you’ll have to change any other details (such as ad width and height if you’re not using a large rectangle).

    03. Save Template. You are done.


    If you are finding blogger code implementation hard, then try our Blogger to WordPress Service

    Scripts Sources:

    That concludes this simple and useful tutorial. Hope you like it.



    Related Posts From Network
    Print

    About the Author

    When I was born I was so shocked I didn't speak for a year and half...... My brain has 2 parts, Right and Left, The Right one has nothing left in it and the Left one has nothing right in it......Who says Nothing is Impossible?? I've been doing nothing for years......

    View Comments to “Show Adsense Only to Search Engine Visitors”

    Author comments are in a darker gray color for you to easily identify the posts author in the comments

    1. Daniel says:

      Thanks for that tutorial. Does it also works with WP-Super-Cache?

    2. Bariski says:

      Thanks for your reply. Yes it does with super cache.

    3. Daniel says:

      hmmm, there is a problem with the php code. th ad will only be displayed on the first page the visitor lands on. If the visitor navigates to another page, the ad will disapper.

    4. Bariski says:

      I have never tried this hack with any of my online blogs, so I can’t be sure about that but you seems pretty right on that one. A javascript hack with a cookie feature (if available) will make it perfect for super cahce also. I will look for alternate solution, and if i will find it, will post it.

    5. Thanks for this awesome tutorial! I will try to use this after google adsense has approve my request. Once again Thanks! *bookmarks ;)

    6. Daniel says:

      Thanks for that tutorial. Does it also works with WP-Super-Cache?

    7. Bariski says:

      Thanks for your reply. Yes it does with super cache.

    8. Daniel says:

      hmmm, there is a problem with the php code. th ad will only be displayed on the first page the visitor lands on. If the visitor navigates to another page, the ad will disapper.

    9. Bariski says:

      I have never tried this hack with any of my online blogs, so I can’t be sure about that but you seems pretty right on that one. A javascript hack with a cookie feature (if available) will make it perfect for super cahce also. I will look for alternate solution, and if i will find it, will post it.

    10. Thanks for this awesome tutorial! I will try to use this after google adsense has approve my request. Once again Thanks! *bookmarks ;)

    11. Thank for sharing this code. What a great idea to target the ads to SERP visitors instead of all the regulars.

    12. Philip Ze says:

      Nice trick, do you mind I incorporate this function into my Quick Adsense plugin (http://techmilieu.com/quick-adsense), a credit line will be given to this post inside the plugin code.

    13. Thank for sharing this code. What a great idea to target the ads to SERP visitors instead of all the regulars.

    14. Philip Ze says:

      Nice trick, do you mind I incorporate this function into my Quick Adsense plugin (http://techmilieu.com/quick-adsense), a credit line will be given to this post inside the plugin code.

    15. Bariski says:

      Sure no problem. Thanks.

    16. Sean says:

      But you don't take your own advice. That's okay, I rarely take my own either. :D

    17. Bariski says:

      Sure no problem. Thanks.

    18. Sean says:

      But you don't take your own advice. That's okay, I rarely take my own either. :D

    19. dhimas says:

      Wow fast trackback.. Very very nice article..

    20. Bariski says:

      Thanks for the appreciation buddy.

    21. dhimas says:

      Wow fast trackback.. Very very nice article..

    22. Bariski says:

      Thanks for the appreciation buddy.

    23. Andycam says:

      Nice Tutorial, thx for that!

    24. Andycam says:

      Nice Tutorial, thx for that!

    25. Rob says:

      looks like this content is really from Cats who code…. Tsk tsk

    26. Bariski says:

      The reference links in the end of the post refer to the original posts from where this is inspired, please have a look there.

    27. Arpit says:

      For wordpress users there is a plugin: Who see Ads. Simplifies your task – no coding required. :)

    28. BouledogueFrançais says:

      STOLEN FROM

      SO SAD…

    29. Bariski says:

      The reason I edited you link is because, first read the full article, the full credits are given to the sites from where this article has got inspiration.

    30. Rob says:

      looks like this content is really from Cats who code…. Tsk tsk

    31. Bariski says:

      The reference links in the end of the post refer to the original posts from where this is inspired, please have a look there.

    32. Arpit says:

      For wordpress users there is a plugin: Who see Ads. Simplifies your task – no coding required. :)

    33. BouledogueFrançais says:

      STOLEN FROM

      SO SAD…

    34. Bariski says:

      The reason I edited you link is because, first read the full article, the full credits are given to the sites from where this article has got inspiration.

    35. BTP says:

      i think it is great idea, but we must have a good SEO and have nice SERP. For me, i think i can't put this trick. Cause my site doesn't have enough visitor from search engine.

      But once again…. nice….

      Best regard

    36. Bariski says:

      Thanks for your reply. Appreciate it.

    37. BTP says:

      i think it is great idea, but we must have a good SEO and have nice SERP. For me, i think i can't put this trick. Cause my site doesn't have enough visitor from search engine.

      But once again…. nice….

      Best regard

    38. Bariski says:

      Thanks for your reply. Appreciate it.

    39. Cosmin says:

      Here's another interpretation of this method.

      The difference is this one shows whatever you want in case visitors are NOT coming from a search engine ;)

      http://ow.ly/VAtA

    40. Bariski says:

      Very nice find buddy.

    41. Cosmin says:

      Thanks :)

      I needed something to show up on my blog if visitors were not coming from Google, so this little thingie takes care of it nicely ;)

      Hope others will find it useful :)

    42. Cosmin says:

      Here's another interpretation of this method.

      The difference is this one shows whatever you want in case visitors are NOT coming from a search engine ;)

      http://ow.ly/VAtA

    43. Bariski says:

      Very nice find buddy.

    44. Cosmin says:

      Thanks :)

      I needed something to show up on my blog if visitors were not coming from Google, so this little thingie takes care of it nicely ;)

      Hope others will find it useful :)

    45. Jim Danby says:

      “which means more clicks”…

      Er, no. Unless you believe that search engine visitors will click more to make up for the loss of clicks from other sources.

    46. Jim Danby says:

      “which means more clicks”…

      Er, no. Unless you believe that search engine visitors will click more to make up for the loss of clicks from other sources.

    47. favSHARE says:

      This article has been shared on favSHARE.net. Go and vote it!

    48. favSHARE says:

      This article has been shared on favSHARE.net. Go and vote it!

    49. Sameer says:

      Could this be implemented within the ads that we paste in templates? cos I use adsense plugin, so i just write [ad] to insert an ad, which is fast an easy.. you mean I'd have to have this code always handy so that i can paste [ad] within it?

    50. Sameer says:

      Could this be implemented within the ads that we paste in templates? cos I use adsense plugin, so i just write [ad] to insert an ad, which is fast an easy.. you mean I'd have to have this code always handy so that i can paste [ad] within it?

    51. Something wrong says:

      Something bad happened… I must have done something wrong, but the blog and the wp-admin have disappeared…

    Comments are closed.

    blog comments powered by Disqus