Tim Laughlin's Everything VB.NET Blog


AdSense and Community Server

Though I focus on Google Adsense in this article I would suspect other providers would work very similarly.  There are couple of areas that need to be understood to get this all to work together.

Overview

You will need to set up an account with Adsense.  They will then review your application and decide if your content meets their criteria.   I can't say exactly what their criteria will be, but most general audience sites would probably be approved.  They will not approve adult content. Once Google gives you an account you can log in and create the injection scripts you will need in the steps outlined below.

Editing the Skin file

The first skin file you will want to modify is Skin-Ads.ascx which is in the /Themes/default/Skins directory.  You can copy this to your desired skin directory if you desire.  A reason you may choose to do that is so ads only showing up on a blog for example.  The Community Server skinning system will use the skin hierarchy to find the right file.

The first thing you want to do is delete:

<div align="center" style="padding-top:5px;padding-bottom:5px;">
<iframe width="486" height="60" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" bordercolor="#000000" src="http://www.communityserver.org/Banner.aspx?z=1">
</iframe>
</div>

from the StandardTop span.  This code is only a place holder for Community Server and will display when you turn on ads later.  If you copied you skin file to a different l skin directory you will also want to delete this from the Skin-Ads.ascx in the default theme so that you don't get text in other parts of you site when you turn on ads.

You will notice inside the Skin-Ads.ascx there are six span tags: StandardTop, Square, Skyscraper, StandardBottom, GoogleAdsense, and Inline.  You can use all of these for Adsense, you are not limited by the span named GoogleAdsense. One thing to remember is Google will only display up to three ad blocks per page, so don't put more then three on any given page.  Anything after the third one in the rendered html will be blank. 

Add your different channels within different spans in your skin-ads file and save it when you are done.  As way of example here is the abbreviated skin file for this site:

<%@ Control Language="C#" %>
<span id="StandardTop" runat="server" visible="false">
<script type="text/javascript"><!--
...
google_color_url = "ECECEC";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

</span>

<span id="Square" runat="server" visible="false">
<script type="text/javascript"><!--
....
google_color_url = "336699";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</span>

<span id="Skyscraper" runat="server" visible="false">
</span>

<span id="StandardBottom" runat="server" visible="false">
<br/>
<script type="text/javascript"><!--
...
google_color_url = "336699";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</span>

<span id="GoogleAdsense" runat="server" visible="false">
<div class="AdsenseArea">
<script type="text/javascript"><!--
....
google_color_url = "336699";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</span>

<span id="Inline" runat="server" visible="false">
</span>

 Then you are going to want and add lines like    

<CS:Ads ID="Ads1" Zone="Square    " runat="server" />

Make sure the ID attribute in unique for each <CS:ads.. on your page.  Zone should the span name from the skin-ads.ascx file.

On this site I am running it with just the one blog, and I am not worried about ads in other sections.  If you are running a full blown Community Server install you may want search all you skin files for Zone=" and see which zone might show up where. 

Okay, we are ready to turn them on.  Go to Control Panel / Administration/ System Tools.  Select Manage ads.

Select enable ads, for now uncheck the SystemAdminstrators from the role to exclude and press save.  The ads should appear where you put the <CS:Ads elements.  If thing aren't right uncheck enable ads hit save.  Now no ads go back adjust your shins and try again.  Note it could take some time before relvent ads appear.  Google will need to index your site and match content to ads.

Hope this helps.  If you choose to join Adsense, do me a favor and use my referal link by clicking on the adsense icon in the left nav.

Love to hear about your success in getting this running on your site.

Please note:  After writing this blog entry it came to my attention that you must be running Community Server Comercial Editon to use AdSense.  It is excluded from the Personal Edition in the EULA.   

Comments

Community Server Daily News said:

news of the day a grab bag for what's happening in Community Server Dennis van der Stelt gives us another

# December 7, 2006 5:15 PM

The Wizard said:

Hi Tim,

Great post on ads, you do know about the inline ads editor ability in Community Server don't you?

You just have to enable inline ads in the control panel and then double click the top and bottom ad sections to add your code.

While this will not work for blogs it works for the rest of the main site.

# December 7, 2006 5:49 PM

Daily News List Blog said:

Tim Laughlin walks us through the steps required to setup Google Adsense on Community Server.

# December 7, 2006 5:56 PM

Prog said:

news of the day a grab bag for what's happening in Community Server Dennis van der Stelt gives us another

# December 7, 2006 6:38 PM

tlaughlin said:

Hey Wizard,

That is why you are the Wizard.  Now that you mention the inline editing of ads the light goes on.  Noticed that once on dev site and apparenty forgot about is as quickly as I discovered.  Thanks for the reminder.  

I will play with that some more.  

# December 7, 2006 7:47 PM

gjcradle said:

Just read this post along with your other one about CS SP2. Looked at the new licensing matrix and it appears that you can't display google ads if you're using a personal license.

# December 8, 2006 6:49 AM

tlaughlin said:

Look at that, another change in the EUlA, or my original oversight, not sure which.  But I am in violation of the Personal Edition.  Guess I am buying Standard License sooner than I thought.

Thanks for pointing that out GJ Cradle.  

# December 8, 2006 8:57 AM

gjcradle said:

You and me both it would seem. I wouldn't mind betting that we're far from being the only ones.

# December 8, 2006 10:51 AM

Community Server Bits said:

Tim Laughlin walks us through the steps required to setup Google Adsense on Community Server.

# March 12, 2007 7:58 AM