homepage Welcome to WebmasterWorld Guest from 54.81.170.186
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

    
ASP Code to randomize ad's
randomize adsense ads
jplwebdesign




msg:1335656
 12:53 am on Nov 15, 2005 (gmt 0)

Hi all - I thought I'd share this piece of code I use to randomize ads on pages. I know adsense allows you to randomize a particular ad, but I wanted a way to randomize different sized ads, not just colors. The below code does exactly this. Feel free to mess around with it. It can be programmed to randomize an infinite number of ads and colors. I use this on several web sites.

SAMPLE ASP CODE

<%
dim images1, stDisplayImage1
Randomize

stDisplayImage1 = int(rnd * 2) + 1
%>
<%if stDisplayImage1 = 1 then%>
----adsense code #1
<%else%>
----adsense code #2

<%end if%>

 

Ankhenaton




msg:1335657
 1:26 am on Nov 15, 2005 (gmt 0)

stDisplayImage1 = int(rnd * 2) + 1

I assume this rnd goes from 0 to 0.99?

so extremes are int(0 * 2) = 0 + 1 = 1

and int(0.99 * 2) = 1 + 1 = 2

I think you would be faster just doing

rnd and do
if stDisplayImage1 < 0.5 adsense 0 else adsense1

then you could also assign probabilities of 0.6 0.7 etc if one of them proves more succesful IF sometimes interchanged with the other just to have not always the same on the spot to draw attention.

You might want to check out also other distributions like beta but the differences might be academic.

Cool would be something like bayesian or genetic algorithms clientside but since we are not allowed to fiddle with the javascript you have to do it via channels and by handcopying the data :(

<%if stDisplayImage1 = 1 then%>
----adsense code #1
<%else%>
----adsense code #2

<%end if%>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved