How to put ads on your blog
and make money
- How to put ads on Blogger?
- How to put adsense ad below the post title in Blogger posts?
- How to place ad after first paragraph in Blogger posts?
Step 1:
Even I have searched these queries when I was using Blogger Blog. I visited many blogs but they didn’t give me solution as per my requirement. So then I have developed my own script which solved all the above queries. I thought this may help you also. So I am sharing that code and procedure with you. This script can place maximum of 3 different types of Adsense ads in your Blogger posts where ever you want to show.
Blogger -> Template -> Edit HTML
Login to Blogger.
Then go to Template and then click on Edit HTML button. Check out below screenshot.
Login to Blogger.
Then go to Template and then click on Edit HTML button. Check out below screenshot.
Step 2:
Search for the below code in your template HTML.
<data:post.body/>
You may find this multiple times. But you need to stop at the second search result from the top of the template.
Next you have to replace the above said <data:post.body/> with below script.
<data:post.body/>
You may find this multiple times. But you need to stop at the second search result from the top of the template.
Next you have to replace the above said <data:post.body/> with below script.
<div id='jobmiddlenew'> <data:post.body/> </div>
<b:if cond='data:blog.pageType == "item"'>
<style> #addcode1{display: none;} </style>
<div id='addcode1'>
<!--Place your parsed Ad code 1-->
</div>
<style> #addcode2{display: none;} </style>
<div id='addcode2'>
<!--Place your parsed Ad code 2-->
</div>
<style> #addcode3{display: none;} </style>
<div id='addcode3'>
<!--Place your parsed Ad code 3-->
</div>
<script type='text/javascript'>
var ad1="<center>"+document.getElementById("addcode1").innerHTML+"</center><br/>";
var ad2="<center>"+document.getElementById("addcode2").innerHTML+"</center><br/>";
var ad3="<center>"+document.getElementById("addcode3").innerHTML+"</center><br/>";
var str1=document.getElementById("jobmiddlenew").innerHTML;
var str2=str1.length;
var n1 = str1.search("<!--adcode1-->");
var firstpart1 = str1.substring(0, n1);
var secondpart1 = str1.substring(n1+14, str2);
if(n1<0){ var newbody1=str1;}
else{ var newbody1=firstpart1+ad1+secondpart1; }
var str3=newbody1.length;
var n2 = newbody1.search("<!--adcode2-->");
var firstpart2 = newbody1.substring(0, n2);
var secondpart2 = newbody1.substring(n2+14, str3);
if(n2<0){ var newbody2=newbody1; }
else{ var newbody2=firstpart2+ad2+secondpart2; }
var str4=newbody2.length;
var n3 = newbody2.search("<!--adcode3-->");
var firstpart3 = newbody2.substring(0, n3);
var secondpart3 = newbody2.substring(n3+14, str4);
if(n3<0){ var newbody3=newbody2; }
else { var newbody3=firstpart3+ad3+secondpart3; }
var strnew=document.getElementsByClassName("post-body entry-content");
strnew[0].innerHTML=newbody3;
document.getElementById("addcode1").innerHTML="";
document.getElementById("addcode2").innerHTML="";
document.getElementById("addcode3").innerHTML="";
</script>
</b:if>
Step 3:
Next step is you have to parse your Adsense ad codes. Click here to use html to xml parser to parse your Adsense ad code. Parsing Adsense code looks like below image.
Next you have to replace <!–Place your parsed Ad code 1–>, <!–Place your parsed Ad code 2–> and <!–Place your parsed Ad code 3–> in the script code with your 3 parsed adsense ad codes of your choice. You can use 1 or 2 or 3 ad codes. This is completely your choice.
Now save the template. You have done the changes in your Blogger Template successfully.
All the steps are done. Now you can use the above adsense ad codes in within your blog posts. But you need to do one more step. Check below.
Every time while you creating blogger posts switch to HTML type and then put <!–adcode1–>, <!–adcode2–>and <!–adcode3–> for the respective Adsense ads in your post where ever you want to show ads. Check below screenshot.
Copy from below and paste them in your blogger template because these are case sensitive and also there should not be any extra characters with these codes.
<!--adcode1-->,<!--adcode2-->,<!--adcode3-->
If you want show 3 ads in blogger post then use all <!–adcode1–>, <!–adcode2–> and <!–adcode3–>.
If you want show 2 ads in blogger post then use combination of 2 of <!–adcode1–>, <!–adcode2–> and <!–adcode3–> as of your choice.
If you want show only 1 ad in blogger post then use any one of <!–adcode1–>, <!–adcode2–> and <!–adcode3–>.
If you want show 2 ads in blogger post then use combination of 2 of <!–adcode1–>, <!–adcode2–> and <!–adcode3–> as of your choice.
If you want show only 1 ad in blogger post then use any one of <!–adcode1–>, <!–adcode2–> and <!–adcode3–>.
If you put any one adcode from <!–adcode1–>, <!–adcode2–> and <!–adcode3–> at the starting of the post itself it will show the ad below the post title.
By following the above step by step process you can easily display ads where ever you want in Blogger post. You can edit and make changes in the above script code as per your requirement. This trick works for all Blogger Templates. If you have any queries let us know through comments.
Edited by: FL Media Group.
No comments:
Post a Comment