how to make an ad in the middle of posting articles on blogger


1. Go to Edit Template, find the code <data:post.body/>. If there are multiple tags <data:post.body/>, look for those enclosed by conditional tags <b:if cond=’data:blog.pageType == "item"’>.

2. After that, change the code <data:post.body/>, with the following code:

<div expr:id='"ads1" + data:post.id'></div>
<div style="clear:both; margin:10px 0">
ADSENSE ADVERTISING SCRIPT THAT HAS BEEN PARTSED
</div>
<div expr:id='"ads2" + data:post.id'><data:post.body/></div>
<script type="text/javascript">
var obj0=document.getElementById("ads1<data:post.id/>");
var obj1=document.getElementById("ads2<data:post.id/>");
var s=obj1.innerHTML;
var t=s.substr(0,s.length/2);
var r=t.lastIndexOf(" ");
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+1);}
</script>

3. Save your template, and see the results.

It should be noted, the script above will place the ad right in the middle of the post, or in other words, the script will count all the words in your article and then divide it into 2 (see line of code var t = s.substr (0, s.length / 2);), then inserts an advertisement at that point.

Note: To parse Adsense code, you can use this Parse Tool.

So if your article is long enough, the ad will appear a little further down.

If you want, you can change the divisor '2' with another number, for example '6'. Then the article will be divided into 6 sections, and the ad will be inserted in the first 1/6 section. Feel free to experiment.

What if I want to freely place my ad in the middle of my post wherever I want?

Again, if that's what you want, you'll need to organize via post edit. However, it is different from the method I have previously described, namely by using a table, this time I give a much more practical and easy way.

You just need to change the script code above a little, which is on the line var t = s.substr (0, s.length / 2); and 2 lines below, with the code:

var r=s.search(/x3C!– adsense –x3E/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r); obj1.innerHTML=s.substr(r+16);}

So the whole thing looks like this:

<div expr:id='"ads1" + data:post.id'></div>
<div style="clear:both; margin:10px 0">

ADSENSE ADVERTISING SCRIPT THAT HAS BEEN PARTSED

</div>

<div expr:id='"ads2" + data:post.id'><data:post.body/></div>
<script type="text/javascript">
var obj0=document.getElementById("ads1<data:post.id/>");
var obj1=document.getElementById("ads2<data:post.id/>");
var s=obj1.innerHTML;
var r=s.search(/x3C!-- adsense --x3E/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);
obj1.innerHTML=s.substr(r+16);}
</script>

Next, when you create a post, or edit it, place the & lt;! - adsense - & gt; tag. wherever you want to place Adsense ads. Remember, to insert the tag & lt;! - adsense - & gt; in HTML mode.

Please choose which method is more suitable for you. The two ways above, both place adsense ads by taking up space in the middle of the article, if you want an ad to the right of the article for example (with text-wrapping), you can add additional code to the ad script that has been parsed earlier.

So it will be like this:

<div style='float:right; margin: 0px 0px 0px 10px'>
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>

So, please apply. Hopefully it will be able to increase the CTR of ads on your blog. If there are difficulties, or things that are not clear, feel free to ask through the comments.

Yuk komennya!

Previous Post Next Post