How To Add Adsense Ads In The Post With Callers Using JavaScript

How To Add Adsense Ads In The Post With Callers Using JavaScript - In this trick you will place the Adsense ads in the post with the caller. With this trick then we can save Adsense ads anywhere in the post according to our will. Actually this is almost the same as how to save Adsense ads in the post manually, only here we do not store the ad code directly in the post, but we only save the caller code only.

So with this we can easily replace ad units or replace ads with other accounts without having to edit the posts one by one. We just need to replace the ad code in HTML edit only.

Actually on Google has many articles that discuss how to store adsense ads in the post automatically, but there are some bloggers who feel uncomfortable with the way because of the placement of ads in the post out of our control in full.

How To Add Adsense Ads In The Post With Callers Using JavaScript

For that you can try this trick, so the ads will appear in accordance with our will. To start trying to save Adsense ads in the middle of posting with this caller, For more details can directly follow the steps below.

How To Add Adsense Ads In The Post With Callers Using JavaScript


Go to Blogger >> Settings >> click the Theme menu >> Edit HTML, Then, place the following code, above the code </body>

<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 replace the code I marked with such code from your Adsense ad code. Notice each quotation mark of the ad code with single quotes instead of double quotes.

Then please use this code to call ads, please save in the post as you want in the mode of posting HTML.

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

If you want to save another ad, please create again 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 the second ad, please save it in the post as you wish in the HTML posting mode.

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

Done, and you can see the results.

That's the tips I can share, about How To Add Adsense Ads In The Post With Callers Using JavaScript. Hopefully with articles that I have shared above can be useful and useful for you all. Good luck.

Provide comments relevant to the posted articles and provide critiques and suggestions for the progress of the blog