How to Save Adsense Ads In Posts With Callers Using Javascript

How to Save Adsense Ads In Posts With Callers Using Javascript

How to Save Adsense Ads In Posts With Callers Using Javascript

How to Save Adsense Ads In Posts With Callers Using Javascript


The trick to save Adsense ads in posts with this caller I made because there was a request from a friend of Magic Company. With this trick, we can store Adsense ads anywhere in the post as we wish.

Actually this is almost the same as how to save Adsense ads in posts manually, it's just that here we don't save the ad code directly in the post, but we only save the caller code.

So with this we can easily replace ad units or replace ads with other accounts without having to edit posts one by one. We just need to replace the ad code in HTML edits only.
Actually, in Google there are already many articles that discuss how to save adsense ads in posts automatically, but there are some bloggers who feel uncomfortable with this method because the placement of ads in the post is beyond our full control.

For that you can try this trick, so that the ads will appear according to our wishes.

To start trying tricks to save Adsense ads in the middle of posts with this caller, please copy the code below above </body> or can be stored in an 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 replace the code that I marked with a code like that from your Adsense ad code. Pay attention to each quotation mark from the ad code with single quotation instead of double quotation.

Then please use this code to call the ad, please save in the post as you wish in HTML post mode.

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

If you want to save other ads, please create the code above again 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 in the post as you wish in HTML post mode.

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

May be useful.

Buka Komentar

Advertiser