Blogger Template Code for Google Adsense Ads

You may have noticed that there are no Google Ads on the homepage of Digital Inspiration. That's because the content on the blog mainpage is updated so frequently that contextual advertising bots (read Adsense) may not be able to serve really relevant ads.

We do run Google advertising on individual posts (called Itempages in Blogspot jargon) and Archive webpages but not on the frontpage. Implementing this style of advertising in your Blogspot blog is easy though it helps if you know a bit about editing Blogger Templates and Template Tags.

Adsense Blogger Template Code
Here's a snippet of the HTML code from our Blogger Adsense template that will help you display Adsense Ads only on Itempages but not on the Mainpage. This template will also convert your blog post titles into hyperlinks only on the homepage and archives but the titles will continue to appear as static text in individual post pages.

<MainOrArchivePage>
<Blogger> <BlogDateHeader>
<h2 class="date-header"><$BlogDateHeaderDate$></h2> </BlogDateHeader>
<a name="<$BlogItemNumber$>"></a> <BlogItemTitle><BlogItemUrl><a href="<$BlogItemUrl$>"> </BlogItemUrl>
<h3><a href="<$BlogItemPermalinkURL$>"><$BlogItemTitle$></a></h3>
<BlogItemUrl></a></BlogItemUrl> </BlogItemTitle>
<$BlogItemBody$>
</Blogger>
</MainOrArchivePage>

<ItemPage><Blogger><BlogDateHeader>
<h2 class="date-header"><$BlogDateHeaderDate$></h2> </BlogDateHeader>
<div class="post"><a name="<$BlogItemNumber$>"></a> <BlogItemTitle><BlogItemUrl><a href="<$BlogItemUrl$>"> </BlogItemUrl>
<h3><$BlogItemTitle$></h3>
<BlogItemUrl></a></BlogItemUrl> </BlogItemTitle>
===== Google Ad Code goes here ======
<$BlogItemBody$>
</Blogger>
</ItemPage>

The above HTML code is written for the classic Blogger template. If you have upgraded to the drag-n-drop layout templates of new Blogger, the code may require some adjustments but the basic implementation principle would stay the same.

Related: Free Blogger Templates, Hide Blogger Bar

Find this article at: http://labnol.blogspot.com/2007/04/blogger-template-code-for-google.html

web: http://www.labnol.org/ email: amit@labnol.org

Reader Comments

I use this code to display ads on item page in new blogger:-

[angular bracket starts]b:if cond='data:blog.pageType == "item"'[angular bracket ends]

adesnse code

[angular bracket starts][slash]b:if[angular bracket ends]

for showing ads on a particular post page we can use:-

cond='"blog post URL" == data:blog.url'

Thanks Amit Ji,
I have successfully Implemented this code in my blog ApniTally

Your post couldn't come on any better time!
I was struggling with this kind of Adsense implementation for the last few days, but couldn't really figure out.
Thanks again for sharing.
You rock!!! :)

Hi Amit, I was wondering if you can help me with something :) I have updated to blogger-beta and my blog is using the drag-n-drop adsense method (which I find to be a little buggish at the time). There is no option to specify a particular channel for a particular ad-unit. Although, its a breeze to edit the colours or the publisher id, I still haven't been able to specify a custom channel for my ad units. For the time being, I'm using url-channels in adsense, but in my view they aren't as accurate as custom channels. So, any suggestions?

Hi Amit,
In response to Atunu's comment above :
Add the adsense code in a Html/Javascript Page Element so you can include the channel code also. Full details here :
How To Add Adsense in New Blogger

Cheers!

Hello. I can put adsense in each individual page post in Blogger, but i don't know how to put this ads in only one specific page. I try with the code posted by Rupesh cond='"blog post URL" == data:blog.url' , but i don't get any result. Where i have to put the url of the post? How i have to add it, can make an example please? Thanks. Regards from Spain.

Amit,

Can you guide me as to where should I add the above code?

Do I need to replace something, inorder to implement the same?

Please do reply whenever you have some time at hand.

« Back to main



Google Custom Search