Hello, I want to randomly display my adwords banner and a banner hosted on my site. Is there any way to do this? Here is what the adsense looks like: <script type="text/javascript"><!-- google_ad_client = "pub-9713982568167945"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text"; google_ad_channel =""; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> Code (markup): and the banner is: http://www.thepartylive.com/banners/BANNER468X60-2.gif Basically I just want a script, similar to a random image script to alternative between these two and possibly more in the future. Any idea how I can do this? My site for reference: http://www.volconvo.com Thank you!
Gotta be a simple php random function right? x=random(1) if x=0 show ad1 else show ad2? I'd go with something a little more decisive myself, so you can get an accurate split, if that is the goal.
What platform does your site run on? I could code you a quick ASP snippet to do this. Not sure if it's against AdSense TOS or not, but thats for you to worry about PM me if you're interested.
As long as you do not make any changes within the adsense code, you are fine I think. To do it, you can just create files, adsense.txt and adsense2.txt and randomly include them within your page. Here is a post at shoemoney's blog that helps you do it: http://shoemoney.com/2005/09/12/code-to-rotate-easily-between-adsense-and-ypn/
I used to do it like this Put all your code into a database and display it like so. Worked quite well for me. function ads() { global $connect; $result = mysql_query("SELECT * FROM ads ORDER BY RAND(NOW()) LIMIT 1", $connect) or die ("query 1: " . mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows > 0) { $row = mysql_fetch_array($result) or die ("query 2: " . mysql_error()); } return $row['code']; } Code (markup): This way in the future you simply add a row to the database upload the banner and you have a new banner showing on your site.
Wait I'm confused... do I just paste this code: < ?php $number=mt_rand(1, 2); if ($number=="1") { include "adsense.txt"; #include the text file with adsense code } else { include "YPN.txt"; #include the text file with ypn code } ?> Code (markup): into my header and where include is link to my actual text files (include "http://www.volconvo.com/YPN.txt") I am confused
hey, hmm.. I put <?php $number=mt_rand(1, 2); if ($number==1) { include "http://www.volconvo.com/adsense.txt"; } else { include "http://www.volconvo.com/banners.txt"; } ?> Code (markup): Into my header template in vbulletin where I want it to appear and it is blank. I thought by adding the http://www.volconvo.com/ location for the .txt files would help but it did not... I put the .txt files in both my /forums/ dir and my main dir because I was not sure where it would look for them. Still blank... Any ideas?
I am not very familiar with php but I think there is some include_path in the php settings or something like that... Maybe a php professional can help here