A Precarious Balance

Sean Winstead's web site & blog
Welcome to A Precarious Balance Sign in | Join | Help
in Search

A Precarious Balance

Sean Winstead's web site & blog

Using Google Adsense in Community Server

UPDATE: This post changed to incorporate the recommendation left by David Rhodes in the comments.

There's some good information in the Community Server forums about displaying Google Adsense ads in Community Server. This Howto post provides the basic method for doing so. However, later in the thread, the issue of displaying Google ads more than once on the page came up and was left without a final solution. I was able to do it successfully. For evidence, see the ads on this blog post.

Disclaimer: In this situation, I am using the same Adsense layout in both positions. This post does not show how to display two different Adsense layouts on the same page.

Here's how I did it...

  1. Open skin file Themes\Default\Skins\Skin-Ads.ascx
  2. Locate the span with id GoogleAdsense.
  3. Between the <span> and </span> tags, paste a copy of your Google Adsense code. Following is an example from my Skin-Ads.ascx. So that the ads would match the layout of the page, I added a new style to Themes\Default\Styles\blog.css and surrounded the Google-generated script with a div referencing the style.

    <
    span id="GoogleAdsense" runat="server" visible="false">
      <div class="AdsenseArea">
        <script type="text/javascript"><!--
          google_ad_client = "pub-3080852261786875";
          google_ad_width = 468;
          google_ad_height = 60;
          google_ad_format = "468x60_as";
          google_ad_type = "text";
          google_ad_channel ="";
          google_color_border = "E6E6E6";
          google_color_bg = "E6E6E6";
          google_color_link = "A9501B";
          google_color_text = "000000";
          google_color_url = "006699";
          //--
    ></script>
          <script type="text/javascript"
            src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </div>
    </span>
  4. Open file Themes\Blogs\Default\LayoutTemplate.ascx.
  5. Insert a CS:Ads control into the file, before and after the div containing the CS:BodyControl element. Following is an example of the CS:Ads control:

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

Following is some of the markup from my own LayoutTemplate.ascx file:

<Blog:BlogTitleHeader id="bth" runat="server" />
<
Blog:CurrentSearch id = "cs" runat = "Server" />
<CS:Ads ID="Ads1" Zone="GoogleAdsense" runat="server" />
<br />
<
div class="CommonContent">
   <CS:BodyTemplate id="BodyTemplate" runat="Server" />
</
div>
<
br />
 <CS:Ads ID="Ads2" Zone="GoogleAdsense" runat="server" />

I have seen the case where Adsense doesn't display any content in the bottom CS:Ads control. I assume that's because there was nothing pertinent to the content in that blog post. But as mentioned earlier, this scheme has successfully displayed ads in two locations on a page.

--
Sean Winstead

Tags: ,

Published Thursday, June 29, 2006 11:00 PM by Sean Winstead

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

A Precarious Balance said:

While on the subject of placing Google ads in a Community Server site (see previous post), Seth Godin...
June 30, 2006 6:47 AM
 

Community Server Daily News said:

news of the daya grab bag for what&amp;#39;s happening in Community ServerKen Robertson reflects on his two
June 30, 2006 2:49 PM
 

Community Server Daily News said:

news of the daya grab bag for what&amp;#39;s happening in Community ServerKen Robertson reflects on his two
June 30, 2006 2:51 PM
 

Community Server Daily News said:

news of the daya grab bag for what&amp;#39;s happening in Community ServerKen Robertson reflects on his two
June 30, 2006 2:53 PM
 

Community Server Daily News said:

news of the daya grab bag for what&amp;#39;s happening in Community ServerKen Robertson reflects on his two
June 30, 2006 3:02 PM
 

Bryant Likes's Blog said:

Just upgraded the sqlxml.org blogs to community server 2.1 . One of the features that I was interested
August 14, 2006 3:59 PM
 

Dave said:

I would place the <div class="AdsenseArea"> inside skin-ads.ascx rather than around the <cs:ads /> control, that way it will not get rendered if ads are turned off.
September 1, 2006 4:25 AM
 

Sean Winstead said:

Hi Dave,
Thank you for pointing that out to me! I have used your idea on this website and will update the post.
September 1, 2006 10:42 PM
 

Community Server Bits said:

Sean Winstead details how he added Google Adsense to Jerilyn&#39;s Live Well the Days blog. Very tastefully

March 12, 2007 11:01 AM
 

hakan uzuner said:

thank you for information

September 9, 2008 2:23 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit