Jump to content
xisto Community
Brian Gillingham

Smart Php Code -- Firefox Product Referrals Unit to display either Google Referral Ads / Google AdSense for conten

Recommended Posts

If you are like me, you have a Google AdSense account. You would like to get more product referrals for Firefox, wouldn't you?

 

I wrote some PHP script that will either displays the Google - Firefox Referral" banner to non-Firefox users or your "Google AdSense for content" banner.

 

If you didn't know, I believe that you only get product referrals for Firefox when a non-Firefox user downloads and installs the program - the target audience is non-Firefox users. This smart script never displays the Firefox referral to Firefox users, but shows the Google AdSense for content ads.

 

Important: you must configure the parts in the code below to match your google <script> HTML block that you get when you access your Google AdSense account. Also, be notified that all double-quotes have been changed to single-quotes in the separate "echo" blocks.

 

<?php  // SET THESE VALUES!!  $yourpub = "pub-################";  $colborder = "2F5F91";  $collink= "4040DD";  $col_bg = "F0F2F7";  $coltext = "3F3F3F";  $colurl = "008000";   $browserinfo = $_SERVER['HTTP_USER_AGENT'];  if ( strpos($browserinfo, 'Gecko') )  {	if ( strpos($browserinfo, 'Netscape') )	  $nonfirefox = 'YES';	else if ( strpos($browserinfo, 'Firefox') )	  $nonfirefox = 'Mozilla Firefox (Gecko/Firefox)';	else	  $nonfirefox = 'YES';  }  else if ( strpos($browserinfo, 'MSIE') )  {	if ( strpos($browserinfo, 'Opera') )	  $nonfirefox = 'YES';	else	  $nonfirefox = 'YES';  }  $showit = 1;  // initialize to show the Google Ad  if ( $nonfirefox == 'YES' ) {	// change the second parameter below if you want to display the Firefox  	// product referral less frequently... shouldn't really exceed 10 or so... 	// change random calculation and any comparisons as needed 	$showit = rand(0, 3);	if ($showit == 3) {	  // display the Firefox Product referral Ad, but give the user a small testimonial	  echo "	  <center>		<small><font color='green'>I believe they do it better... and they are ahead of the curve.</font>  		<b>Download the latest version</b>.</small><br>	  </center>	  <script type='text/javascript'><!--	  google_ad_client = '$yourpub';	  google_ad_width = 468;	  google_ad_height = 60;	  google_ad_format = '468x60_as_rimg';	  google_cpa_choice = 'CAAQtYiYhAIaCPydp1XAd3jZKOm293M';";	}  }  if ($showit < 3) {	// display the Google Ad	echo "	<script type='text/javascript'><!--	google_ad_client = '$yourpub';	google_ad_width = 468;	google_ad_height = 60;	google_ad_format = '468x60_as';	google_ad_type = 'text_image';	google_ad_channel ='';	google_color_border = '$colborder';	google_color_link = '$collink';	google_color_bg = '$col_bg';	google_color_text = '$coltext';	google_color_url = '$colurl';";   }  // common ending for both blocks of Google Ad code  echo "  	//--></script>	<center>	  <script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'>	  </script>		</center>	<br>";?>

Of course, you should save this code as a separate unit - "googleads.php" and include it anywhere you want by using an include statement.

 

<?php include "googleads.php" ?>

Share this post


Link to post
Share on other sites

Wow, this a very useful script. This is a great idea. I think that Google should do this by default, show the Firefox referral to browsers other than Firefox!Thanks.

Share this post


Link to post
Share on other sites

Aren't they only promotioning the toolbar? or the firefox download too?


I use a couple blocks of code now - so I have multiple google Adsense promotions handled in that code block. It randomly decides which promo to display. PM me if interested in a new sample of my code.

Share this post


Link to post
Share on other sites

Very interesting, original and usefull.I will try this out, thanks for sharing with us this " "genius" php code"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.