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.

Guide: How To Randomize Adsense Colors

Discussion in 'Placement / Reviews / Examples' started by Zedzero, Sep 27, 2006.

  1. #1
    Well, nothing complicated here. this is just a simple php function. every coder can code it in under a minute, but i'm writing this for those who can't :) I coded it for myself, and thought some may find it useful.

    what does it do:
    it randomizes any color of your ads for each visitor, each time.

    what you will need:
    1. a host that supports php

    steps
    1. add this function to wherever your functions are, or to the page you have adsense ads.

    
    function randomcolor()
    {
    	$r = rand(0, 200);
    	$g = rand(0, 200);
    	$b = rand(0, 200);
    	
    	$colorcode = base_convert($r, 10, 16).base_convert($g, 10, 16).base_convert($b, 10, 16);
    	echo($colorcode);	
    }
    
    Code (markup):
    2. when adding your adsense code, edit it like this:

    
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "<?randomcolor();?>";
    google_color_text = "000000";
    google_color_url = "000000";
    
    Code (markup):
    you can apply <?randomcolor();?> to any other color codes as you wish. but be advised that, currently it is optimized for white background. if you wish to change it, you may need to edit those 3 lines:

    
    $r = rand(0, 200);
    $g = rand(0, 200);
    $b = rand(0, 200);
    
    Code (markup):
    they generate colors which are not so close to white, so that google will not use default colors instead of yours.

    about google adsense tos:
    this can not put you in a difficult position against google, be assured.
     
    Zedzero, Sep 27, 2006 IP
    fezbucks and EGS like this.
  2. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #2

    TOS
    after all you are actually CHANGING the original google code
    hence i would never be that sure about your TOS compliance

    and since there are other options - like the original Google oprions to change colors ....

    did you actually verify the TOS compliance with a formal request to Google about your precise example or is this just an assumption
     
    hans, Sep 27, 2006 IP
  3. Zedzero

    Zedzero Peon

    Messages:
    322
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i saw it coming :)

    google tos is based on making html edits. this is a server based edit, that will OUTPUT code compliant to TOS.

    if you apply this and then view your sites source code, you will see that it is TOS compliant.
     
    Zedzero, Sep 27, 2006 IP
  4. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #4
    that means you did NOT really verify this particular sample with Google
    Google however is open to respond to such kind of requests for clarification
    a long time ago i did a different approach and submitted for clarification to Google and got an official approve

    it maintains peace of mind to have such
    the output is the same - but the original code IS modified
     
    hans, Sep 27, 2006 IP
  5. Zedzero

    Zedzero Peon

    Messages:
    322
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i understand your concern.

    i gave my word on compliance, and made my point regarding code edits. if you don't trust my word, it is understandable that you don't use this little code.

    btw, it is also possible to do that without editing code. but i didn't need it since i trust my own word :)
     
    Zedzero, Sep 27, 2006 IP
  6. jackburton2006

    jackburton2006 Peon

    Messages:
    5,296
    Likes Received:
    282
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yet another superfluous breaking of the TOS in the service of God knows what reason. If you're going to risk getting ban from such a potentially valuable program, then at least do it for a big reward, not just changing your banner colors.
     
    jackburton2006, Sep 27, 2006 IP
  7. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #7
    myself i have NO need to use your code
    my concern are for all others who might want to try it
    your word in God's ears - but your word might cost millions of $ if several people use the code and would get banned by G for TOS violation and refer to your word to refund in full their lifetime adsense NON-revenue ...

    i would never do such changes without real and direct Google aproval - its free and just an email to G to get it and to get peace of mind for all and to be free of an $ liability for your word
     
    hans, Sep 27, 2006 IP
  8. Zedzero

    Zedzero Peon

    Messages:
    322
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you really don't know the difference between server-side code and simple html, right?

    can you tell whether the following code is edited or not? DOES it matter if you can tell?

    <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxxxxx";
    google_ad_width = 336;
    google_ad_height = 280;
    google_ad_format = "336x280_as";
    google_ad_type = "text_image";
    google_ad_channel ="xxxxxxxxxx";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "000000";
    google_color_text = "000000";
    google_color_url = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    Code (markup):
     
    Zedzero, Sep 27, 2006 IP
  9. jackburton2006

    jackburton2006 Peon

    Messages:
    5,296
    Likes Received:
    282
    Best Answers:
    0
    Trophy Points:
    0
    #9
    What I want to know is, how you can make a statement like this:

    Without proof of Google telling you it's okay. If some noob uses this because of your assurances, and he gets banned or warned against it, what's he going to say, "B-b-b-but Zedzero assured me it wasn't against the TOS!" Give me a break and stop making bold pronouncements that you can't back up.
     
    jackburton2006, Sep 27, 2006 IP
  10. Zedzero

    Zedzero Peon

    Messages:
    322
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #10
    i gave my word and you told your concerns clearly.
    i think now noobs can decide on their own with the knowledge of both side of the story. :)
     
    Zedzero, Sep 27, 2006 IP
    daniah likes this.
  11. daniah

    daniah Well-Known Member

    Messages:
    1,092
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    138
    #11
    There is no question of anyone getting banned by using this piece of code. This code is run on the server side and simply selects a random color, the output of the code is 100% google compliant, this can easily be verified by looking at the output of the code which is perfectly legit
     
    daniah, Sep 27, 2006 IP
    EGS and Zedzero like this.
  12. jackburton2006

    jackburton2006 Peon

    Messages:
    5,296
    Likes Received:
    282
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Again, how can you say that? Why don't you and the other guy Email Adsense Support about this, then come back with the answer. THEY are the only ones who can give assurances, and even then they can change their minds tomorrow.
     
    jackburton2006, Sep 27, 2006 IP
    Cheap SEO Services likes this.
  13. daniah

    daniah Well-Known Member

    Messages:
    1,092
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    138
    #13
    The adsense support comes into picture if you make any changes in the adsense code displayed on a page. Since the adsense code which will appear on the page is strictly per TOS there will be no problems
     
    daniah, Sep 27, 2006 IP
  14. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #14
    without a email from google it means nothing
     
    ahkip, Sep 27, 2006 IP
    Cheap SEO Services likes this.
  15. Mike32

    Mike32 Guest

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    cool, thanks!
     
    Mike32, Sep 28, 2006 IP
  16. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #16
    You are right once again. It does not matter what anyone says what GA will or will not do. It is safe and easy to flick them an email to get it in concrete!

    Col :)
     
    Cheap SEO Services, Sep 28, 2006 IP
  17. gmeyer

    gmeyer Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    I use to rotate colors and even different ads (Google/Amazon) by
    randomly including different unchanged snippets of code
    via PHP. I never had any problems (or even concerns) about that
    practice, because the delivered html-code definitely is complying
    with all the Google rules.

    Now my concerns are rising ;-)
    What do you think about that?
     
    gmeyer, Sep 28, 2006 IP
  18. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #18
    that is the normal way to do and fully approved by Google.
    this method of randomly selecting a complete original google adsense code with different color palette has been discussed much earlier in another thread here in DP forum

    by then I have submitted the procedure howto SSI adsense to Google and received a friendly positive reply which is published as well for general reference in above linked page.
     
    hans, Sep 28, 2006 IP
  19. 010081

    010081 Banned

    Messages:
    4,657
    Likes Received:
    222
    Best Answers:
    0
    Trophy Points:
    0
    #19
    thankx this has been a cool thread
     
    010081, Sep 28, 2006 IP
  20. aleahey

    aleahey Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #20
    I find it disturbing that so many people have such a small amount of knowledge of PHP and server-side coding.

    There would be no way for Google to tell you were using this.
     
    aleahey, Sep 28, 2006 IP