how to put adsense ads after the Fourth paragraph

 



SSalam everyone, on this occasion I will share how to install Adsense ads after the umpteenth paragraph, meaning that you are free to determine in which paragraph the ads will be displayed.

I have also applied this method to this blog, where I display an ad after the 2nd paragraph and after the 12th paragraph in this blog post.

and what if my post is less than paragraph 12 then the ad will not be loaded or displayed, because I have an ad set that only appears after paragraphs 2 and 12.

of course this method is very useful for the convenience of visitors because the ads that appear will adjust the length of our article, if the article is short then the ads that appear are also few, if the article is long then the ad will also adjust.

ok so if you want to try it let's see how below.

How to Install Adsense Ads after the Fourth Paragraph

please go to blogger select it temaand edit htmllook for the code <data:post.body/> usually there are more than one depending on the template used, you can choose the one in the conditional tag of the post page, if you don't understand just try one - one. if you find it, add this html code under the code <data:post.body/> and don't forget to replace <!-- AdSense Ad Code Here --> with your ad unit code


<div class='Blogger-StoreParagrafAds'>
<!-- your ads show here -->
</div>

if the ad does not appear / blank, it is recommended to parse the ad code and please try again

and finally put the javascript below above the </body> code if you don't find it it's probably already parsed so it will look like <!--</body>--></body>

<b:if cond='data:view.isPost'>
<script>
//<![CDATA[
function Blogger-StoreParagrafAds(e){let a=document.getElementsByClassName("Blogger-StoreParagrafAds")[0];if(a){let n=document.querySelectorAll(".post-body p")[e-1];n.parentNode.insertBefore(a,n.nextSibling)}}Blogger-StoreParagrafAds(3);
//]]>
</script>
</b:if>

pay attention to the number 3 that I marked, meaning that the ad will appear after the 3rd paragraph, please change it as needed, it is also important to use the <p></p> tag when creating a new paragraph, otherwise the ad will not appear

the script above is only for 1 ad, so if you want to add a 2nd and 3rd ad, you can use the same script by adding numbers in the Blogger-StoreParagrafAds class to Blogger-StoreParagrafAds 2 and Blogger-StoreParagrafAds 3 and so on

ok so that 's the way to put adsense ads after the paragraph to so hopefully useful.



Post a Comment

Previous Post Next Post
Marwat Tech

let's build a community