Skip to main content

follow us



This time, iweblogsite will discuss about How to Save Adsense Ads In the Post with Javascript Caller Code. Actually this is the same way, how to save Adsense ads code in posts manually, only here we do not save the ad code directly in the post, but we only store the caller code with javascript. curious? let's discuss below

Actually, in Google there have been many articles discussing how to save adsense ads in posts automatically, but there are some bloggers who feel uncomfortable in this way because the placement of ads in posts is out of our control in full. For that you can try this trick, so that the ad will appear according to our will.

Also read : Add Widget Disquss Recent Comment for AMP Blog HTML

How to Save Adsense Ads In the Post with Javascript Caller Code


To start trying to save Adsense ads in posts with this caller, please copy the code below above /body or can be save in the HTML / JavaScript widget in the sidebar or footer.


<script>
//<![CDATA[
var element = document.getElementById("insertad");
element.innerHTML = "<ins class='adsbygoogle' data-ad-client='xxxxxxxxxxxxx' data-ad-format='auto' data-ad-slot='xxxxxxxxx' style='display:block'></ins>";
var newScript = document.createElement("script");
var inlineScript = document.createTextNode("(adsbygoogle = window.adsbygoogle || []).push({});");
newScript.appendChild(inlineScript);
element.appendChild(newScript);
//]]>
</script>

Please change the code that I mark with a code like that from your Adsense ad code. Pay attention to each quotation mark from the ad code with a single quote not double quotation. Then please use this code to call ads, please save in the post as you wish in HTML posting mode :


<div id="insertad"></div>

If you want to save other ads, please create the code above with a different caller ID. You can use the following code for the second ad.


<script>
//<![CDATA[
var element2 = document.getElementById("insertad2");
element2.innerHTML = "<ins class='adsbygoogle' data-ad-client='xxxxxxxxxxxxx' data-ad-format='auto' data-ad-slot='xxxxxxxxx' style='display:block'></ins>";
var newScript2 = document.createElement("script");
var inlineScript2 = document.createTextNode("(adsbygoogle = window.adsbygoogle || []).push({});");
newScript2.appendChild(inlineScript2);
element2.appendChild(newScript2);
//]]>
</script>

And use this code to call a second ad, please save it in the post as you wish in HTML posting mode.


<div id="insertad2"></div>


How? hopefully useful for you. please share this article with your other friends. That's all about How to Save Adsense Ads In the Post with Javascript Caller Code. Thanks for visiting iweblogsite.

credit : kompiajaib

You Might Also Like

Newest Post
Comment Rule Please leave your comment below. Comments wich contain links will not show up before we approved. Thank you for visiting iweblogsite
Open Comment