Wednesday, November 15, 2006

Wrapping your Adsense code inside your post

For the past couple of weeks, I've been busy studying different things so as to increase my Adsense earnings. I studied a little bit of Javascript and came up with the following tweak so as to put your Adsense ads inside your post. You will see this code at work at my Wantusawa blog. You'll notice that the Adsense ad is actually inside the post. So, how did I do that? Here is the step by step guide:

1. Back up your template first, ok?
2. Look for <$BlogItemBody$> tag in your template.
3. Replace <$BlogItemBody$> tag with the code below:
<div id="first<$BlogItemNumber$>"></div>

<MainPage>
<table align=left><tr><td>
YOUR ADSENSE CODE (square or rectangle format)
</td></tr></table>
</MainPage>
<ItemPage>
<table align=left><tr><td>
YOUR ADSENSE CODE (square or rectangle format)
</td></tr></table>
</ItemPage>

<div id="last<$BlogItemNumber$>">
<$BlogItemBody$>
</div> <br />

<MainPage>
<script language="JavaScript">
var obj0=document.getElementById("first<$BlogItemNumber$>");
var obj1=document.getElementById("last<$BlogItemNumber$>");
var s=obj1.innerHTML;
var r=s.search(/<adsense>/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+9);}
</script>
</MainPage>
<ItemPage>
<script language="JavaScript">
var obj0=document.getElementById("first<$BlogItemNumber$>");
var obj1=document.getElementById("last<$BlogItemNumber$>");
var s=obj1.innerHTML;
var r=s.search(/<adsense>/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+9);}
</script>
</ItemPage>

4. Republish your blog.
5. Now, it's ready. The next step is to mark the place in your post where you want your Adsense ads to appear. How? Use the <adsense> tag.

Example.

This is a post. This is longer post. <adsense> This is another post. This is another post. Etc. Etc.

The ad will appear on the place where you put the tag.

That's all folks!

Note: This only works on current Blogger version, this is not for Beta.
You can put the Adsense Ad to the right by simply changing the align=left to align=right on the table tag.

8 comments:

digital coverage said...

Thank you very much... very useful

loui$$ said...

Did there any wrap for blogger beta?i really thirst for it!PM me please,thanks!

Arpit said...

Is doing so comes under the Terms and conditions of Google Adsense?? Means can we modify the javascript?

kukote said...

@arpit... I did not modify the javascript of the Adsense code, as you can see, it stays the same on "PUT YOUR ADSENSE CODE HERE". The javascript I wrote simply seperate your blog post into two, putting the first part before the adsense code and the other part after the adsense code. I believe, no TOS violation was done here because the adsense code remain as it is.

Anjali said...

I dont have that <$BlogItemBody$> tag in my template. I've tried to do this before and failed miserably. What am I doing wrong?

E Akino said...

good day, i tried how to do this but i can't find the <$BlogItemBody$>, kindly check my blog http://kabayan-junction.blogspot.com, why don't i have this code on my template. thankz man

Ayisha said...

Nice and knowledgeable sites for everyone-
booksshelf
knowledge
books
liberary
kitaben
Books and references
books
tutorial books

SweetSol said...

hi! I am new at blogging, I also tried adsense (siempre, gusto ko ring kumita), but unfortunately, as the others, i could not find that <$BlogItemBody$> on my template. San nga ba makikita yan?

Wednesday, November 15, 2006

Wrapping your Adsense code inside your post

For the past couple of weeks, I've been busy studying different things so as to increase my Adsense earnings. I studied a little bit of Javascript and came up with the following tweak so as to put your Adsense ads inside your post. You will see this code at work at my Wantusawa blog. You'll notice that the Adsense ad is actually inside the post. So, how did I do that? Here is the step by step guide:

1. Back up your template first, ok?
2. Look for <$BlogItemBody$> tag in your template.
3. Replace <$BlogItemBody$> tag with the code below:
<div id="first<$BlogItemNumber$>"></div>

<MainPage>
<table align=left><tr><td>
YOUR ADSENSE CODE (square or rectangle format)
</td></tr></table>
</MainPage>
<ItemPage>
<table align=left><tr><td>
YOUR ADSENSE CODE (square or rectangle format)
</td></tr></table>
</ItemPage>

<div id="last<$BlogItemNumber$>">
<$BlogItemBody$>
</div> <br />

<MainPage>
<script language="JavaScript">
var obj0=document.getElementById("first<$BlogItemNumber$>");
var obj1=document.getElementById("last<$BlogItemNumber$>");
var s=obj1.innerHTML;
var r=s.search(/<adsense>/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+9);}
</script>
</MainPage>
<ItemPage>
<script language="JavaScript">
var obj0=document.getElementById("first<$BlogItemNumber$>");
var obj1=document.getElementById("last<$BlogItemNumber$>");
var s=obj1.innerHTML;
var r=s.search(/<adsense>/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+9);}
</script>
</ItemPage>

4. Republish your blog.
5. Now, it's ready. The next step is to mark the place in your post where you want your Adsense ads to appear. How? Use the <adsense> tag.

Example.

This is a post. This is longer post. <adsense> This is another post. This is another post. Etc. Etc.

The ad will appear on the place where you put the tag.

That's all folks!

Note: This only works on current Blogger version, this is not for Beta.
You can put the Adsense Ad to the right by simply changing the align=left to align=right on the table tag.

8 comments:

digital coverage said...

Thank you very much... very useful

loui$$ said...

Did there any wrap for blogger beta?i really thirst for it!PM me please,thanks!

Arpit said...

Is doing so comes under the Terms and conditions of Google Adsense?? Means can we modify the javascript?

kukote said...

@arpit... I did not modify the javascript of the Adsense code, as you can see, it stays the same on "PUT YOUR ADSENSE CODE HERE". The javascript I wrote simply seperate your blog post into two, putting the first part before the adsense code and the other part after the adsense code. I believe, no TOS violation was done here because the adsense code remain as it is.

Anjali said...

I dont have that <$BlogItemBody$> tag in my template. I've tried to do this before and failed miserably. What am I doing wrong?

E Akino said...

good day, i tried how to do this but i can't find the <$BlogItemBody$>, kindly check my blog http://kabayan-junction.blogspot.com, why don't i have this code on my template. thankz man

Ayisha said...

Nice and knowledgeable sites for everyone-
booksshelf
knowledge
books
liberary
kitaben
Books and references
books
tutorial books

SweetSol said...

hi! I am new at blogging, I also tried adsense (siempre, gusto ko ring kumita), but unfortunately, as the others, i could not find that <$BlogItemBody$> on my template. San nga ba makikita yan?