Ajax and ohhh.. Adsense

Discussion in 'AdSense' started by missenlinx, Dec 7, 2006.

  1. #1
    Did bit of search but thought i'd ask you guys as your always keen to help :p


    I've got a DB each user adds what albums they own... hoping adsense at the bottom will target the hundreds of key words on the page relating to music..

    but its display adds about key loggers.

    this page of music is getting pulled from an ajax request. can google read that or what ?
     
    missenlinx, Dec 7, 2006 IP
  2. kh7

    kh7 Peon

    Messages:
    2,715
    Likes Received:
    109
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Probably not. Ajax is difficult for search engines, so it is likely difficult to combine with adsense as well. Be very descriptive in your meta tags (including key-words) on pages like that.
     
    kh7, Dec 7, 2006 IP
  3. missenlinx

    missenlinx Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    great.... thanks anyway... anyone got any information from another site for me ?
     
    missenlinx, Dec 7, 2006 IP
  4. wissam

    wissam Well-Known Member

    Messages:
    2,289
    Likes Received:
    78
    Best Answers:
    1
    Trophy Points:
    185
    #4
    My friend, after the Ajax script use the tag
    
    <noscript>Print same content on the ajax request here, at least the first request or the keywords</noscript>
    
    Code (markup):
    This could help, and don't forget the Meta Tags ...
     
    wissam, Dec 7, 2006 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    You are not allowed to use Adsense on Ajax generated content, you can place a non-dynamic ads to which reflect the starting content, but thats as far as you can go.

    Peace,
     
    Barti1987, Dec 7, 2006 IP
  6. missenlinx

    missenlinx Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    sorry buddy I know what noscript does but how can that help target the adds ?
     
    missenlinx, Dec 7, 2006 IP
  7. Correctus

    Correctus Straight Edge

    Messages:
    3,453
    Likes Received:
    389
    Best Answers:
    0
    Trophy Points:
    195
    #7
    Ajax won't help, sorry

    IT
     
    Correctus, Dec 8, 2006 IP
  8. kh7

    kh7 Peon

    Messages:
    2,715
    Likes Received:
    109
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The google-adsense bot will look at your page, desperately seeking info on what the page is about. So if you have an ajax page, where the subject isn't clear for the bot, thing like meta-tags and no-script text will be the only information it has to go on: and use it too.
     
    kh7, Dec 8, 2006 IP
  9. abuzant

    abuzant Well-Known Member

    Messages:
    956
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #9
    Sorry, but I disagree.

    I have a website (see below) that is very similar in the way it works. It was veeeeery hard to figure out a way that will combine having AJAX working, and adsense that is related at the same time. But it is achievable.

    Please notice that the example below assumes you (want to) have 3 adsense blocks, 728x90, 250x250 and 160x600... changes to fit any design are as easy as ABC...

    In your <head> section, have something like:

    
    function _render(keyword)
    {
       var adspace1 = document.getElementById('ad_iframe1');
       var adspace2 = document.getElementById('ad_iframe2');
       var adspace3 = document.getElementById('ad_iframe3');
    
       // reload ads in AJAX page
       adspace1.innerHTML = '<iframe src="getAdsense.php?kw='+keyword+'&w=728&h=90" border="0" frameborder="0" width="728" height="90">'+keyword+'</iframe>';
    
       adspace2.innerHTML = '<iframe src="getAdsense.php?kw='+keyword+'&w=250&h=250" border="0" frameborder="0" width="250" height="250">'+keyword+'</iframe>';
    
       adspace3.innerHTML = '<iframe src="getAdsense.php?kw='+keyword+'&w=160&h=600" border="0" frameborder="0" width="160" height="600">'+keyword+'</iframe>';
    }
    
    Code (markup):
    The function above should be called after your AJAX part of the page rendering process has completed. Using moo.fx for example, they have a function called onComplete which starts after AJAX has completed its work, this is where we fire our function called _render with some related keyword.

    Now, the contents of the iFrame are pulled from a PHP script as you see above which is called getAdsense.php.. Here is the code for the getAdsense PHP script page..

    
    <?php
       ini_set("display_errors", "off");
       error_reporting(0);
    
       $keyword = $_GET["kw"];
       $height = $_GET["h"];
       $width = $_GET["w"];
    
       /*
             Width & height are ANY VALUES accepted by the adsense program
       */
    ?>
    <script type="text/javascript">
    <!--
        google_alternate_ad = "[B]http://xxxxxxxxxxxxxx[/B]";
        google_ad_client = "[B]PUB-xxxxxxxxxxxxxx[/B]";
        google_ad_width = <?=$width?>;
        google_ad_height = <?=$height?>;
        google_ad_format = "<?=$width?>x<?=$height?>_as";
        google_ad_channel = "[B]xxxxxxxxxxxxxx[/B]";
        google_color_border = "EAECEE";
        google_color_bg = "EAECEE";
        google_color_link = "1177AA";
        google_color_url = "445563";
        google_color_text = "445563";
    //-->
    </script>
    <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
    <div style="display: none; visibility: hidden;">
    <br /><br />
    <h1><?=$keyword?></h1>, more about <h2><?=$keyword?></h2>.. read the latest <h3><?=$keyword?> articles</h3>, <h4><?=$keyword?> news and resources</h4>
    </div>
    
    Code (markup):
    So..
    That getAdsense.php will load your adsense block code with the provided width and height.. and will also have a hidden DIV that contains some keywords related to what the end user sees in the adsense block.. i hope this makes some sense? :D

    finally, your template page..
    Just where you want the ads to appear (that will reload with AJAX), make sure you change the adspace holder to look as follows..

    
    <!-- Start Adsense 'Ajaxified' Dynamic Block -->
    <div id="ad_iframe[B]1[/B] (or 2, or 3 of course)">
            [B]YOUR NORMAL ADSENSE CODE HERE[/B]
    </div>
    <!-- End Adsense 'Ajaxified' Dynamic Block -->
    
    Code (markup):
    Conclusion...
    The tweak above will do the following in a user's session..
    • When a user first visits the page, they see regular adsense block in 3 DIV spaces called ad_iframe1, ad_iframe2 and ad_iframe3
    • When the AJAX action takes effect (time to reload ads), a javascrip function is invoked which will reload the DIV's content from a PHP script.
    • The PHP script will show a predefined-sized adsense blocks along with hidden keywords that will make sure the ads are relative to that content the AJAX part just rendered.
    Friends, i would have never explained it better that this.. i tried by best so good luck :D I have it working here at TheDamnCool.NET where you can see the code in action.

    If in anyway did this code help you, please leave me a greenie, good luck.
     
    abuzant, Dec 8, 2006 IP
    Computer(Jew) likes this.
  10. wissam

    wissam Well-Known Member

    Messages:
    2,289
    Likes Received:
    78
    Best Answers:
    1
    Trophy Points:
    185
    #10
    Very good stuff, keep it up abuzant .
     
    wissam, Dec 8, 2006 IP
  11. abuzant

    abuzant Well-Known Member

    Messages:
    956
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #11
    Thanks Wissam, i just felt the need to share something that took me too long to accomplish, and by the way gave good results :D
     
    abuzant, Dec 8, 2006 IP