July 02, 2007

Adsense beneath Blogger post titles or at end of posts

A key placement of AdSense is within the body of a blog post. You can easily feature ad units beneath every post title or at the end of each post by adding AdSense code to your templates HTML. Here's what to do to achieve this.

  1. Log into your AdSense control panel and choose the ad unit you would like to be displayed. Be sure to keep the width of your posts in mind: some are wide enough to feature a 468x60px banner, while others may be restricted to the half-banner width of 234px.
  2. Copy the code and paste into a text editor (such as Notepad). You'll need to change some of the characters in this code in order for it to display in your blog. Don't worry, this doesn't contravene Google's T&C's for AdSense, as I'll explain later.
  3. Your code will look something like this: You'll need to change the < and > in red to the following:
    < = &lt ; > = &gt ;
  4. Now, log in to your Blogger dashboard and go to Template>Edit HTML, and tick the "Expand widget templates" box. Ensure that you backup your template before making any changes.
  5. Find this section of code using the search function of your browser (usually CTRL+F):
    <p><data:post.body/></p>
  6. To feature ads immediately after your post titles, insert your AdSense code just before this section in your template. To feature ads at the end of every post, paste the code immediately after instead.
  7. Save your template to see the ads in action!

Do be aware that if there are more than 3 ad units on a page, not all of the ads will be displayed; if you feature a number of ads on your main Blogger page, ads will not display in all of the posts, though they should be displayed on the post pages.

As I mentioned earlier, modifying the AdSense code in the way I have described will not contravene AdSense terms and conditions: all you are doing is substituting the < and > for the HTML encoding for these characters. When you look at the source code for the page, the AdSense code will display as it was originally written. This modification will not alter the functionality of the code at all, and ensures that it will be displayed. The code as first presented will not display in the body of Blogger posts!

For examples of how this code should be implemented into your blog template, take a look at this page (opens in a new window).

Next: How to display ads in the body of the post itself.

Technorati Tags:

Advertise on Blogger Buster

Browse through the Archives

All existing posts are still available to view while I'm working on the site, albeit seen in a much simpler interface. Feel free to browse through the archives to find tutorials, templates and articles to help you build a better blog:

Blog Archive

© Blogger Buster 2010 Home | About | Contact | Hire Me | Privacy Policy