Free Google Third-Party Ad Providers Widget

On February 26, 2008 Google updated it’s AdSense program’s terms to include the following language:

“You must have and abide by an appropriate privacy policy that clearly discloses that third parties may be placing and reading cookies on your users’ browser, or using web beacons to collect information, in the course of ads being served on your website. Your privacy policy should also include information about user options for cookie management.”

On May 22nd, 2008 the AdSense team sent out an email announcing that they would now be accepting third-party ads on the AdSense network, and that if a publisher wanted to opt in to show those ads on their websites, they must update their privacy policies, this time including links to those third-party
advertisers:

“If you choose to allow third-party ads on your site, please update your privacy policy to inform your visitors that third-party vendors may serve ads on your site. Please also provide links to these vendor websites and inform your users that they may opt out of cookies (if the vendor offers this capability).”

Since the list of third-party ad providers on Google clearly states: “At its sole discretion, Google reserves the right to change this vendors list at any time”, I decided to provide a few easy methods for webmasters to include a version of the list that will automatically update itself.

I provide the list as an XML feed. You can see the feed here: google-third-party-ads.blogsblogsblogs.com. It looks like a normal webpage, because I styled it using an xsl stylesheet, but if you view source on the page you can see that it is actually a valid XML document:

Google Third Party-Ad Providers XML
(click to enlarge)

PHP provides some easy functions for working with XML, if you are comfortable with those.

I also provide the list as serialized data. For many people this will be easier than working with XML, since simply calling the unserialize() function will turn the list into a PHP array. To grab the serialized data, simply append ?output=serialized to the address, like such:

http://google-third-party-ads.blogsblogsblogs.com/?serialized=true

As long as your privacy page can process PHP (ie. if the extension is .php, or you have it set up to parse PHP inside HTML files), you can just copy and paste the following code where you want the list to appear in your page:

<?php
$thedata = unserialize( file_get_contents( 
"http://google-third-party-ads.blogsblogsblogs.com/?serialized=true" ) );
$providers = $thedata["provider"];
echo '<ul>\n';
foreach( $providers as $provider ){
	$ptitle = $provider["title"];
	$purl = $provider["url"];
	echo '<li><a href="$purl">$ptitle</a></li>\n';
}
echo '</ul>'; 
?>

You will have to replace the funky single and double quotes with regular ones to use that code snippet in a PHP page.

Lastly, I provide the list as Javascript widget. Perhaps the easiest of all is the free Google third-party ad providers widget. Simply cut and paste this code into any HTML page (no PHP required) and the list will appear in it’s place when someone visits the page:

<script type="text/javascript" src=
"http://google-third-party-ads.blogsblogsblogs.com/gtpap.js" 
id="gtpapwidget"></script>
<span>List provided courtesy of 
<a href="http://google-third-party-ads.blogsblogsblogs.com/" 
target="_blank">blogsblogsblogs.com</a></span>

You can style the widget any way you want, since each of the main HTML elements generated has a unique id associated with it, and explained on this page. Hope this helps make following the new terms easier. 🙂

3 thoughts on “Free Google Third-Party Ad Providers Widget”

  1. Thanks for making this. I’m trying the JS version because I can’t show PHP on my blog. The javascript shows blank both on my blog and on an html file I made on my desktop. Is there something obvious that needs to be done here — something so obvious that it shouldn’t have to be mentioned?

  2. B.G. – as far as the file on your desktop, most common thing I can think of that might be wrong is that it has to be an actually HTML document (ie. start and end with <html> and </html>), and the code has to go in between the <body></body> tags. I just tested, and with that as the minimum it worked fine for me. What page did you attempt to put it on? Mind if I look?

Leave a Comment

*