The obvious way is to insert the Adsense code by switching to "HTML" tab in blogger's post editor, but this way has some disadvantages, like:
- If you later chose to not display the adds it will be time consuming to edit each post, especially if you have a blog with many posts.
- You can't change the ads types/sizes, only way is, again, to manually edit each post.
I will show you a different method that has many advantages:
- You can place your ads anyway you want.
- You can edit the way they are displayed at any time (alignment, margins, padding etc.)
- You can easily remove the ads anytime you want.
- You can display ads form other advertising networks, not only Adsense ads.
With this method you will need to insert a piece of code, inside your posts, in the place where you want to display the ads and the rest of is is made from within the template editor.
But enough talk... Here is the best way to insert adsense ads in the middle of your post, or any other specific place.
But enough talk... Here is the best way to insert adsense ads in the middle of your post, or any other specific place.
How to insert Adsense ads in the middle of the post or any other specific place
As always before you do any changes to your template first make a backup!. Go to Template > Backup / Restore > Download full template
Step 1. Firstly you need to convert the adsense code for it to work with the blogger template. This conversion is called "parsing". To do this go -> here <- and paste the adsense code in the box and press "Parse" button.
Step 2. Go to Blog Dashboard > Template > Edit HTML. Now press "Ctrl + F" and search for this part of code in your template:
<data:post.body/>
You will probably find more instances of this code. You will need to modify each of them and see which one works in your case.
Step 3. Now replace the code you found. "<data:post.body/>" with the code below:
Step 3. Now replace the code you found. "<data:post.body/>" with the code below:
<div expr:id='"adsmiddle1" + data:post.id'></div>
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.pageType != "static_page"'>
<div style="clear:both; margin:10px 0">
<!-- Place Adsense Code Here -->
</div>
</b:if>
</b:if>
<div expr:id='"adsmiddle2" + data:post.id'>
<data:post.body/>
</div>
<script type="text/javascript">
var obj0=document.getElementById("adsmiddle1<data:post.id/>");
var obj1=document.getElementById("adsmiddle2<data:post.id/>");
var s=obj1.innerHTML;
var r=s.search(/\x3C!-- adsense --\x3E/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+16);}
</script>
Step 4. Replace the red text <!-- Place Adsense Code Here --> with your parsed adsense code. After that just Save the template.
Step 5. Now all you have to do is place this code (on the HTML tab) in the specific part of the post where you want your ads to be displayed.
Step 5. Now all you have to do is place this code (on the HTML tab) in the specific part of the post where you want your ads to be displayed.
<!-- adsense -->Here's an example:
Other Notes:
Q: Why it doesn't work for me?
A: You probably have more that 1 piece of <data:post.body/> If it doesn't work with the first one, reverse the changes and try the next <data:post.body/>.
Q: What happens if i don't place the <!-- adsense --> inside the post?
A: The ads will be displayed as default, under the post title.
Q: I get an error when i try to save the template...
A: You didn't parsed the adsense code. Check Step 1 again to see how to pares the code.
Q: The adsense ads are displayed incorectly/ looks odd/ are overlapping other page elements.
A: You didn't parsed the adsense code. Check Step 1 again to see how to pares the code.
0 comments:
Post a Comment