I've seen many people ask one question and it seems to be quite an unresolved one. Since I have started adding AdSense ads in the middle of my advertisements, a few people have asked me how they can do the same, but I thought that instead of answering this same question to every individual, I could easily write a post about it for everyone to read.
First of all, let me tell you what is AdSense and how this will work. Firstly, this tutorial is only for bloggers using the Google Blogspot host, so unless you are working on that, this will not work. Next, let me tell you that AdSense is also powered by Google and it is an Ad Network which can help bloggers earn money. So, you can add advertisements anywhere on your blog, but for them to appear in the blog posts, it gets a bit harder. You should do this is you have long blog posts and want to generate more income.
Things Needed
So, in case you want to add some AdSense ads in the middle of your posts, you are going to need a few things -- An approved AdSense account for your blog
- Administrator's approval
- Posts to apply this on.
- Basic HTML editing skills
How to Do This
To Accomplish this Task, you need to follow some steps after making sure you meet all the basic requirements
1. Just to take precaution in case you mess up, head over to the Template section, and take a backup of your Template and store it somewhere safe on your computer.
2. Now that you have a backup, go to Google AdSense and copy any Ad Code that suits the criteria (desired shape and size) for adding them in the middle of posts.
3. Once you have selected the AdSense code, you need to parse it so that it is XML recognizable which is required in this task. To do this, you can use this tool.
4. Next, head on over to the Edit HTML section of the Template Editor. Search for this code snippet-
2. Now that you have a backup, go to Google AdSense and copy any Ad Code that suits the criteria (desired shape and size) for adding them in the middle of posts.
3. Once you have selected the AdSense code, you need to parse it so that it is XML recognizable which is required in this task. To do this, you can use this tool.
4. Next, head on over to the Edit HTML section of the Template Editor. Search for this code snippet-
<data:post.body/>5. You might find multiple instances of this, so you have to stop at the second one. If by the end it doesn't work, then try using the third one.
6. Replace the snippet with this code -
8. You can also replace <center> with a different tag to decide the alignment you want for the ads in your post.
9. Save the changes to your template.
Now, after completing all of these steps, you have done the main important thing. What you can do now is check any of your posts, and what we expect you to see is that all of your in-post ads would be at the very beginning of the posts. Unless you want to keep this as is, you will need to continue further with the tutorial.
<div expr:id='"adsmiddle1" + data:post.id'></div>7. Now, replace <!-- Add here the code of your ad --> with the parsed ad code you generated in step 3.
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.pageType != "static_page"'>
<div style="clear:both; margin:10px 0"><center>
<!-- Add here the code of your ad --></center>
</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>
8. You can also replace <center> with a different tag to decide the alignment you want for the ads in your post.
9. Save the changes to your template.
Now, after completing all of these steps, you have done the main important thing. What you can do now is check any of your posts, and what we expect you to see is that all of your in-post ads would be at the very beginning of the posts. Unless you want to keep this as is, you will need to continue further with the tutorial.
How to Get the Ads in the Middle of the Posts
Whenever you would write a post or to add the advertisements in the middle of an already existing post, you would need to follow these easy steps every time.
1. Locate the place in a post where you want to add the ad in the HTML post editor mode.
2. At the located place, enter this snippet for the ad to appear.
<!-- adsense -->3. Once the post is done, click Save or Publish or Update.
Now, you can check on the post you have applied these 3 steps on and you will e able to find the ad wherever you placed it. So, basically, if you want the ads to be in the middle, you will have to decide its location and do it manually.
I hope that you were able to complete this task and are also able to see the results. Share ith us in the comments how this worked out for you and also write down any problems you are facing. Bye or now! Stay Tuned!
Comments
Post a Comment