A million-dollar question is how to add ads between posts in Blogger? If you want to insert ads into your post content, i.e., it is now possible on Blogger after a certain paragraph. This script actually looks for <br /> tags inside your post and displays the ad unit. You can define a number of <br /> tags to display ads within your post content. A similar feature is already available for WordPress, but Blogger lacks for a long time, but a custom solution can help you.
How to Put AdSense Code in the Blogger Post Body?
What is Additional?
1. Reduced the need for <br /> (line break) tags in his code and using CSS style “clear:both” for the same purpose.
2. Modded this code for center alignment by using HTML5 properties.
3. Add XML code that will load only on the Blogger item page rather than loading on other pages to save your blog performance.
How to Paste Ad Code on Blogger?
Now, I will discuss how to install/ integrate/ inject this script into your blogger theme. (!) Must take a backup of Blogger theme before making any change.
1. Find the <head> tag in your blogger template and place the latest jquery just below it. Please avoid using two jquery links. Remove the older one and use the new version.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>
2. Second look for this code <data:post.body/> inside Blogger theme and replace it with the following code –
<div id="PostBody"> <data:post.body/> </div> <div id="AdCode"> <div style='margin:5px 0;text-align:center;clear:both;'> <!-- Ad Unit Code Here --> </div> </div>
New Blogger template may have 2 or 3 <data:post.body/> code. You should have to identify correct one. Generally 2nd instance of <data:post.body/> is right code to replace in new blogger templates.
3. Now search for </body> tag inside Blogger theme and put the following javascript before/ just above it.
<b:if cond='data:blog.pageType == "item"'> <script> $AdCode = $("#AdCode").html(); $("#PostBody br:lt(1)").replaceWith($AdCode); $("#AdCode").remove(); </script> </b:if>
4. Save the changes made in the Blogger theme and have fun.
You can choose your Ad location –
By replacing the value br:lt(1) with br:eq(n), where n= 1, 2, 3… which is the number of line breaks after which Ad will appear in your post. E.g., If you want to show Ad after the 5th line break, then replace br:lt(1) with br:eq(5), and you are done.
Legal
As far as we know, using this or a similar script to insert ads within your post content is legal because most of the users who are using WordPress, Joomla, etc., are placing ads with the help of similar scripts. It does not matter they are using PHP or javascript. The final choice is yours. You will use it for your blog or not.
GitHub gist – https://gist.github.com/vinayprajapati/5893386
Conclusion
After long research and discussion, we found that adding Google Adsense code inside the post body is possible with javascript. It is absolutely safe to use it. It is our request from Google to give such a feature with Blogger by default.
Nice tutorial. I will try it. is there any plugin we can use to make the task simple?
Plugin? Not yet available for Blogger! :(
Very nice trick to render adsense inside the post..
Hey most welcome on techPrevue, from next time to promotional link in comments
hello Vinay
the tutorial is good and work perfect, but after one day i see the numer of request ads is much
i search on Google and i find
How to fix misconfigured ad request notifications
but i dont understand what do exactly, you can help me!
Observe the ad requests for one or two weeks. This script just shows the ads in middle of posts there is nothing special in that. Please clear me about “misconfigured ad request notifications”… are you unable to use the script?
i do like this tutorial and its work up to there!
misconfigured ad request notifications : for example i have 5.000 visitors have see my ads on website but on this unit ads i add on middle post show me 10.000 visitors!
Okay, I got it. I will try to discover more about it and let you know. One reason I guess is that ad appears below post and then script take it to below certain paragraph there it again appear. This might be a possible reason.
Okey thanks so much Vinay i found something on Google support here : https://support.google.com/adsense/answer/2694805?hl=en
but i dont know if i can fix with that! am waiting ur reply
thanks
I placed the code but for some reason the ad shows up twice, once after the line break and after the end of the post. Any help would be appreciated.
Yes it is a know issue when you use AdSense Asynchronous Ad Unit. We are working to fix it asap.
So if I was the old code will it work?
Unfortunately old units are not available in new AdSense dashboard.
Thanks a Lot…..I think this will increase the revenue of adsence earning…
Most welcome on Tech Prevue. Enjoy!
Yes of course…
any fix to the problem of it showing up at the end of the post?
I’m using it and this is amazing! I’m writing from Italy and you are fantastic. One problem: is there a way to fix the bug that show the ads also at the end of the post? Thanks :)
You are outstanding buddy, this works like charm!!! Awesome!
Indoor Playground Equipmentor soft play is perfect play system for your children.
Hi blog author, thanks for getting this article because I am a blogger and I want to show ads in between articles.
thanks
this code showing blank space middle of page ,not showing ads im using media.net ads
You may need to place ad code within additional div. And define the ad size for this div using CSS.
can you help me to do, this because i cant understand where to put ad code
You can write me an email with your blog URL.
I’m utilizing it and this is astonishing! I’m composing from Italy and you are awesome. One issue: is there an approach to settle the bug that demonstrates the promotions likewise toward the finish of the post? Much appreciated :)
It’s not showing my ads. any help
Do you have AdSense?
With these… I got my fixed up. Thanks man!
Good Tips
Thanks for sharing a very useful post…
I have applied everything but i have one suggestion for you.
Try to show how to replace the ad code with the original adsense code.
thanks u sir, this artical is very helpful
Not working… plz help
Thank! you are amazing
Nice Post Sir
I have Placed my adsense code in the widget section it gas been week but its showing as the blank yellow space but its not still appearing what should be the problem , any suggestions please
Hello thanks for the code. It really did me wonders, worked perfectly on the website.
But I would like to insert two or more ads like on 3rd , 5th and 7th paragraph how do I do that with this code thanks
Hello i added the code o the website and its working perfectly thanks for the code, but i would like to display the ads thrice inside the article. For instance on 2nd paragraph, 4th and 7th how do i implement it
Thank you very much.. it really worked for me: check my blog eksumania_ga
Nice post!
but code not working.
Sir, how can we put AdSense code in blogger article middle.
Plz help and write to me
bsgusainchd@gmail.com
Bro kya ham adsense ke ad ke code copy karke nahi dal sakte???
Kar sakte hain, us tarah se agar aapko position badalani pade to sab post ko ek ek karke edit karna hoga.
How to advertise in the middle of a blogger blog post please tell me
very nice article, thanks for sharing this.
it was indeed helpful.
I place the code as describing but ads are not showing, any idea how much time it will take to show ads between post content.
i guess it will take 24-48hrs to activate the ads, even i just tried on my theyogatradition_blogspot_com/
blog, hopefully waiting for results
Hi,
Do i need to paste the below code before
$AdCode = $(“#AdCode”).html();
$(“#PostBody br:lt(1)”).replaceWith($AdCode);
$(“#AdCode”).remove();
Thanks for sharing this codes. It works out.
Thank you.
Dear Sir,
I using auto ads code,
But ads not showing in post inner content.
Post only showing outside of posts.
Plz help.
I was searching for a long time finally got
automatically same ads started showing below post … is it comply google ads policy ?
Please, is there a way to paste non AdSense ads in between Blogger posts?
It is the same. You may also do it manually.
Hi sir,
I am new to blogger, recently started blogging.
When your free time please check my blog to guide me on how to use AdSense.
Good day to you sir, please I need your help.
I did All you said, but the AdSense is not showing.
Hi Vinay! Thank you for sharing this guide. It worked on my blog, however, the ads are only showing at the bottom of my blog post. How can I show multiple ads in the middle of the blog content/post?
I tried to add ad code inside the post content, but could not do. Let me try another day.
Thanks for the post that help me to add some ads in between the blog posts…
Thanks a lot! I will try this tutorial.
Does it work on any ad network or just AdSense?
This works like magic for me.
In fact, I had to repeat that number line:
It helped me to get another ad space in the article.
Thanks for your help.