1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Coding help

Discussion in 'Programming' started by neha_patelx9x, Oct 18, 2005.

  1. #1
    since many members complained that i should read the terms , i did and heres a little querry ..

    Yahoo and google ads have provision in their terms that their ads cant be displayed on the same page with their competitors' ads.

    IF a site owner wants to keep both Yahoo and Google ads

    and display two banners on a page of the same company ... say one will go in overall_header and one in overall_footer .. (header and footer along with index file makes up the main index.php page)

    can we have some script that will radomly display either yahoo or google in the page index.php .. something like supply a variable with 0 or 1 and 0 for yahoo and 1 for google ... so we see roughly on the long run 50% of each banner on the site on each page load..

    I hope i made it clear in explanation .. (its phpbb)

    http://www.uglued.com/forum/index.php

    IN there i have currently seperated banners based on the theme that users uses , i have two templates but 80% users or more might have Aqua theme and there is yahoo , so yahoo and google is not 50 - 50 ..

    Please feel free to ask me if further clarification is needed on my part.

    Thanks for tkaing time to look into it
     
    neha_patelx9x, Oct 18, 2005 IP
  2. maro

    maro Peon

    Messages:
    356
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I was wondering the same thing! I am not sure, but this would be misleading to them (the bots) and maybe would get you banned??????
    What are your thoughts guys?
     
    maro, Oct 19, 2005 IP
  3. mitchandre

    mitchandre Peon

    Messages:
    313
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This should do it. Please link to site in my sig if do end up using some version of the code below. This assumes you have php installed by the way.

    <?php
    $random_integer = rand(1,10);
    if (is_int($random_integer)) {
    echo 'insert html code used to generate google adds';
    }
    else {
    echo 'insert html to generate yahoo adds';
    }
    ?>
     
    mitchandre, Oct 20, 2005 IP
  4. maro

    maro Peon

    Messages:
    356
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    mitchandre, you code is incorrect, this will have a ratio of 1 to 10 i.e. 90% of the time the second code will be used. rand(1,10) should be rand(0,1)

    And my question is if this is legal and does Google and Yahoo allow this?
     
    maro, Oct 20, 2005 IP
  5. mitchandre

    mitchandre Peon

    Messages:
    313
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Woops, I meant to have it divided by 2. The fixed code is below.

    It seems legal enough to me. As long as yahoo and google are not in direct competition it should be fine.

    <?php
    $random_integer = rand(1,10);
    if (is_int($random_integer / 2)) {
    echo 'insert html code used to generate google adds';
    }
    else {
    echo 'insert html to generate yahoo adds';
    }
    ?>
     
    mitchandre, Oct 20, 2005 IP
  6. neha_patelx9x

    neha_patelx9x Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    most people will agree that u can have this legally ... as on the same page u wont be displaying two different banners ..

    when u sign up with either google or yahoo u are not selling out your website exclusively to them... u still own ur site and u can decide which ads to place on each page load .. i talked to a rep from yahoo and she asked me why i had less page impressions compared to when i started and i told her , i run google ads on one template (theme) and yahoo on other template and that users with template with yahoo ads might be less .. and she said that it was fine ...
    and she hopes that i switch completely to yahoo ... but again its in my hand and they cant say no to having google ads on different page..
     
    neha_patelx9x, Oct 20, 2005 IP
  7. elkiwi

    elkiwi Active Member

    Messages:
    536
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    68
    #7
    I use php if statements to decide how many ad units display on my pages as some topics on my site don't have enought ads to fill 3 units for example. So I just put in something like :

    <?php if ($cat <> 'conservation' && $cat <> 'information') echo '<table  border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td><img src="images/tbl_top_left_cnr.gif" alt="" width="20" height="22" /></td>
    <td class="body_tbl_top"></td>
    <td><img src="images/tbl_top_rght_cnr.gif" alt="" width="23" height="22" /></td>
    </tr>
    <tr>
    <td class="body_tbl_left"></td>
    <td valign="top" bgcolor="#FDFDFF"><p class="menuheads">Sponsored
    <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxxxx";
    google_ad_width = 120;
    google_ad_height = 240;
    google_ad_format = "120x240_as";
    google_ad_type = "text";
    google_ad_channel ="7130692602";
    google_color_border = "FDFDFF";
    google_color_bg = "FDFDFF";
    google_color_link = "0066FF";
    google_color_url = "0066FF";
    google_color_text = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></p>
    </td>
    <td class="body_tbl_rght"></td>
    </tr>
    <tr>
    <td><img src="images/tbl_btm_left_cnr.gif" alt="" width="20" height="21" /></td>
    <td class="body_tbl_btm"></td>
    <td><img src="images/tbl_btm_rght_cnr.gif" alt="" width="23" height="21" /></td>
    </tr>
    </table>' ?>
    Code (markup):
    I don't think there is anything wrong to do what you are suggesting. PHP just spits out the html and so no one is the wiser as to whether it was hard codes or not.

    Google and Yahoo just don't want to see both their ads at the same time on any page.

    I think what you want to do is an interesting idea.
     
    elkiwi, Oct 20, 2005 IP
  8. neha_patelx9x

    neha_patelx9x Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thanks for the coding example and ur nice words :)

    i appreciate ur support :)
     
    neha_patelx9x, Oct 20, 2005 IP
  9. profs77

    profs77 Well-Known Member

    Messages:
    441
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    118
    #9
    Won't that generate a number like 5.42901 most of the time which is not an integer?
     
    profs77, Dec 11, 2005 IP