Results 1 to 11 of 11

[How-To] Implement Adsense Search Only ads (AFS Ads-only)

This is a discussion on [How-To] Implement Adsense Search Only ads (AFS Ads-only) within the Member Articles forums, part of the Focus on Members category; [How-To] Implement Adsense Search Only ads (AFS Ads-only) on your vB 3.x Forum. UPDATE: New Format 2/2011 , jump to: ...

  1. #1
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2

    [How-To] Implement Adsense Search Only ads (AFS Ads-only)

    [How-To] Implement Adsense Search Only ads (AFS Ads-only) on your vB 3.x Forum.

    UPDATE: New Format 2/2011, jump to:
    [How-To] Implement Adsense Search Only ads (AFS Ads-only)


    Google Adsense has recently introduced a new ad program targeting search results pages. It is currently by invite only.
    If you were lucky enough to get an invite to the private beta, this article will help you get set up as it's not 100% clear how to integrate.

    https://code.google.com/apis/afs-ads-only/


    Note, This article is written for vb 3.8.5. I have not tested on any other version, and do not plan to release a vb4.x version any time in the near future (as i haven't upgraded my personal sites yet). It may work on other versions, but they will not be supported in any way and the answer to any questions will simply be "I don't know" as I haven't done it

    Using this new service, you will be able to implement some keyword targeted search results page ads.

    I have not had this integration approved by Google. Use at your own risk of getting your account terminated. I believe it to be ok and run it on my own site, but use at your own description.


    On my site, I incorporated it into the main table of the search results just under the header cell. I think this is the best placement, but you may wish to play with your template a bit.

    search-results_1277183029379.png

    This works based on the keywords put into the search box by the user. vB by default adds some underline and bold html markup to these words in processing, so it is necessary to clean it up.

    Step 1
    Make a new plugin
    vB ACP -> Plugins and Products -> Add New Plugin

    Product: vBulletin
    Hook: search_complete
    Title: "Clean up keywords to pass to adsense" (or anything you want)
    Exe Order: 5
    Php Code:
    Code:
    $displayWords_clean = str_replace('<b><u>', '', $displayWords);
    $displayWords_clean = str_replace('</u></b>', '', $displayWords_clean);
    Active: Yes

    Save the plugin


    Step 2
    Edit the search_results template

    find:
    Code:
    <if condition="$displayCommon">
    <tr>
        <td class="thead" style="font-weight: normal" colspan="$threadcolspan">$vbphrase[words_very_common]: $displayCommon</td>
    </tr>
    </if>
    Add after:

    Code:
    <!-- begin adsense for search -->
    <if condition="$search['showposts']">
    <!-- no ads -->
    <else />
    <if condition="$starteronly">
    <!-- no ads -->
    <else />
    <if condition="$action == 'getnew' OR $action == 'getdaily'">
    <!-- no ads -->
    <else />
    <tr>
    <td colspan="$threadcolspan" class="alt1">
    
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8">
          google.load('ads', '1', {packages: ['search']});
    </script>
    
    <div id="adcontainer"></div>
    <script type="text/javascript" charset="utf-8">
    
          var options = {
            'pubId' : 'pub-xxxxxxxxxxxxx',
            'query' : '$displayWords_clean',
            'container' : 'adcontainer', 
            'format' : 'wide',
            'number' : 4
    
          };
          dynamicAd = new google.ads.search.Ad(options);
    </script>
    
    </td>
    </tr>
    </if>
    </if>
    </if>
    <!-- end adsense for search results -->
    Of course, enter in your adsense Pub Id and you may style to fit your needs and colors of your skin. There are many more optional variables you can use to format the text and display available here:
    https://sites.google.com/a/google.co...nal-Parameters

    A Tip, if you copy/paste anything from the google optional params page, you will have errors. The single quotes copy in as "curly quotes" instead of straight quotes, and cause JS errors, so make sure you replace all the tick marks with a fresh one in the text area of the style manager for anything you copy/paste.

    The IF statement keeps the New Posts and Posts from the past 24 hours as well as "show your threads" and showing posts by member out of the keyword search, and thus out of the ads pull. You likely won't get any ads by search for "JoeQUsername" anyway, so it's best to just leave it off for these.

    Known Bugs:
    Advanced searches for "Unanswered" (ie, search.php?do=process&replyless=1&replylimit=0&don tcache=1) Will return a result set with a small tiny blank TD cell at the top.

    There doesn't seem to be an available condition to block this from loading the widget, thus it shoves a keyword of '' (blank) into the adsense code which returns no ads. As this is not a default search param, i don't think it's a big deal and shouldn't violate any TOS to the best of my knowledge.

    Also, The nested IF's are a bit bulky and can probably be better nested or combined than how I have them. The singular commands (ones that do not equal anything) don't tend to work will within an If or OR multiple conditional, so i left them on their own lines.

    There also seems to be a small display bug issue with IE. I have a question in to google support awaiting feedback. It appears to be their inline iframe styling that is causing the issues.

    Let me know how it does for you! Should make a quick couple bucks I think.
    Last edited by Brian Cummiskey; 02-22-2011 at 02:19 PM. Reason: 2/2011 update
    Brian Cummiskey / Crawlability Inc.
    Security vbulletin - Patch Level for all supported versions released!

    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  2. #2
    Senior Member KURTZ's Avatar
    Real Name
    Christian
    Join Date
    May 2008
    Location
    Italy
    Posts
    287
    Liked
    2 times
    Blog Entries
    6
    anyone has tested it onto the 4.x?

  3. #3
    Junior Member
    Real Name
    wes
    Join Date
    Aug 2010
    Posts
    1
    Liked
    0 times
    hi,

    are you able to list the full optional variables for formatting of the afs ads only ads as I don't have permission to read the links in your article?

    Currently we only have these available but we want to change font size and enable bold etc?

    function init() {
    var options1 = {
    'pubId': 'pub-xxxxxxxx',
    'query': 'xxxxxxxx',
    'container': 'adcontainer1',
    'format': 'wide',
    'number': '4',
    'linkTarget': '_blank',
    'colorText': '#4a4949',
    'colorTitleLink': '#0748bd',
    'colorDomainLink': '#f25604',
    'colorBackground': '#ffffff',
    'channel': 'xxxxxxxx'
    };

    Thanks,
    Wesiwyg

  4. #4
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    If you don't have permission to read the links, then you haven't been approved for this beta service. It is limited to select publishers only.

  5. #5
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    The service has updated the format a bit.

    https://code.google.com/apis/afs-ads...ion-guide.html

    It's basically the same thing, and the key is that little plugin from the 1st post to clean the search query string, so i think you will be able to figure it out without re-writing it completely.

    Just move the first block into headinclude with a conditional:

    Code:
    <if condition="THIS_SCRIPT=='search'">
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8">
     google.load('ads.search', '2');
    </script>
    </if>
    place it right after the other vb main JS

    search_results template ends up looking something like this:
    Code:
    <!-- begin adsense for search -->
    <if condition="$search['showposts']">
    <!-- no ads -->
    <else />
    <if condition="$starteronly">
    <!-- no ads -->
    <else />
    <if condition="$action == 'getnew'">
    <!-- no ads -->
    <else />
    <if condition="$action == 'getdaily'">
    <!-- no ads -->
    <else />
    <tr>
    <td colspan="$threadcolspan" class="alt1">
    
    <script type="text/javascript" charset="utf-8">
    var pageOptions = {
     'pubId' : 'pub-xxxxxxxxxxxxxx',
     'query' : '$displayWords_clean'
    };
    
    var adblock1 = {
     'container' : 'adblock1',
    <if condition="$show['member']"> 'number' : 4,<else /> 'number' : 8,</if>
     'width' : 'auto',
     'lines' : 2,
     'fontFamily' : 'verdana',
     'fontSizeTitle' : '13px',
     'fontSizeDescription' : '12px',
     'fontSizeDomainLink' : '12px'
    };
    
    
    new google.ads.search.Ads(pageOptions, adblock1);
    </script>
    
    
    <div id="adblock1"></div> 
    
    </td>
    </tr>
    </if>
    </if>
    </if>
    </if>
    <!-- end adsense for search results -->
    I added a conditional in there to show more ads to guests than members. You can strip that out and just run 1 number: if you want.

    If you want to run a second unit, you can, as the example provides. I am only using it at the top.

    This version also clears up a lot of the known IE bugs from the 1st post. A much welcomed version
    Last edited by Brian Cummiskey; 02-19-2011 at 05:53 PM.
    Brian Cummiskey / Crawlability Inc.
    Security vbulletin - Patch Level for all supported versions released!

    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  6. #6
    Junior Member
    Real Name
    Ernie Romers
    Join Date
    Jul 2010
    Posts
    1
    Liked
    0 times

    vbulletin 4.X

    Anyone implemented this in version 4?

  7. #7
    Member
    Real Name
    Alessandro
    Join Date
    Dec 2007
    Location
    Italy
    Posts
    92
    Liked
    5 times
    Nothing for VB4?

  8. #8
    vBSEO Staff Brian Cummiskey's Avatar
    Real Name
    Brian Cummiskey
    Join Date
    Jul 2009
    Location
    btwn NYC and Boston
    Posts
    12,789
    Liked
    657 times
    Blog Entries
    2
    Sorry, I never upgraded my personal sites to vb4, and we don't serve ads here, so it was never on the to do list.

  9. #9
    Junior Member
    Real Name
    tommeyboy
    Join Date
    Feb 2009
    Posts
    8
    Liked
    0 times
    Are there plans to upgrade this to vb4.x?

  10. #10
    Junior Member
    Real Name
    Gerald Yuvallos
    Join Date
    May 2008
    Location
    Philippines
    Posts
    28
    Liked
    1 times
    Only thing I can find everywhere is that the variable is {vb:raw criteriaDisplay}... however, no one seems to know how to strip the un-needed tags and characters yet. :(

  11. #11
    Junior Member
    Real Name
    Gerald Yuvallos
    Join Date
    May 2008
    Location
    Philippines
    Posts
    28
    Liked
    1 times
    For vB4, check this thread out -> Help: Strip formatting from {vb:raw criteriaDisplay} - vBulletin.org Forum . I got help from kh99 on vb.org... the code needs to be modified a little though but it works.

Similar Threads

  1. Adsense Search - New?
    By leckley in forum Ad Networks
    Replies: 2
    Last Post: 11-16-2009, 11:56 AM
  2. Replies: 1
    Last Post: 10-26-2008, 12:46 AM
  3. How easy is this to implement?
    By toon in forum Pre-Sales Questions
    Replies: 12
    Last Post: 06-23-2007, 07:19 AM
  4. Adsense for Search
    By reefland in forum Ad Networks
    Replies: 10
    Last Post: 05-03-2007, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •