Wednesday, December 21, 2011

How to Put Adsense on Single Post Only

Do you have your Adsense placed after your post title? And when you look at your home page you see Ads that takes up too much space. Having a mismanaged ads sometimes is annoying, you probably want to clear those unwanted ads that appear on your home page.

Adsense has a built in Options, but has limitations.

You Can't Put Adsense Ads Within Posts.
This is one of the limitations using a built-in Adsense gadget, you cannot place your ads within your post. You can only put them before, after between posts and in the sidebars. But not on your actual post.

Can't Use Channels.
In a Adsense gadget you can't use channels to track the performance of your ad units.
But there's another way, if you want to use channels, simply create your code on your Adsense account, copy paste the code into a JavaScript gadget, instead of using an Adsense gadget.

Put Ads within Post.
Now lets put your Adsense ads within your post. We won't use the Adsense gadget
  1. Get your Adsense code from the Adsense website
  2. Parse the code to replace special characters with HTML entities
  3. In Blogger, go to Layout, then choose Edit HTML
  4. Make a backup of your template by clicking Download Full Template
  5. Click Expand Widget Templates
  6. Search for <data:post.body/> or <p><data:post.body/></p>
  7. Place your Adsense code on the line immediately above this
  8. Save the template.
After the code has been place it will look like this

<div class='post-body entry-content'>
<div style='float: left;'>
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-xxxxxxxxxxxxxxxx&quot;;
google_ad_host = &quot;pub-xxxxxxxxxxxxxxxx&quot;;
google_ad_slot = &quot;xxxxxx&quot;;
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;
</div>
<p><data:post.body/></p>   <---- the code we are looking

Then save the template.
Note: When you put code in you html editor always make it a habit to back up your template by downloading your template. So when an error happens you can always retrieve you template