How to Embed Adsense ads in your Blogger Posts

by Aditya on January 3, 2009

 How to Embed Adsense ads in your Blogger Posts
In this tutorial, I will tell you how to add Google Adsense units in blogger so that they are embedded in your post. It’s pretty easy to do so. It just requires a bit of code work and then it is done. This tutorial will tell you how to replicate this sure-shot formula of ‘advertisement publisher’ success. Now before getting to the tutorial, let us discuss the importance of embedded ads.

Importance of Embedding Advertisement To Your Posts

You must have seen many websites that have Google Adsense ads in their posts (usually on the left side of beginning of the blog post or at the end of the blog post). See the image below for understanding what I meant.
 How to Embed Adsense ads in your Blogger PostsThis is what you blog will look like after following this tutorial. It will create adsense ads embedded to your post. Back to the point, let us discuss the importance of these type of ads and why they are must for publishers.

1. These ads are prominently visible unlike those sidebar and header ads which are missed out by people looking for content.

2. These ads appear in between or just at the end of your content and provide you with better chances of getting more clicks and more money.

3. If you are using ‘read more’ feature on your blog, then your ads will come only when someone visits the post through its unique url and thus, your blog doesn’t give impression of being filled with ads all around.

Embedding Adsense ads in your Blogger Posts

This is quite easy task. You need to follow the steps below and you are done. Now, let us start our work.

1. Login to your adsense account and click on ‘setup ads’.

2. Get ad code for the advertising unit of desired size. (I would suggest you a square advertising unit).

3. Now get your advertising code parsed. You can do that by google adsense parser . Just paste the code in the text are on the web page and click on “Parse” button. This will do the work.

4. Open Notepad (not Wordpad) and save the code generated in step 3 in a file.

5. Now login to your blogger.com account.

6. Click on “Layouts” and then click on “Edit HTML” link.

7. Download your current template by clicking on “Download Full Template”. This may be used in case you messed up with your script. If you feel that your work is not done properly, you can upload this and get your blog in the way it was.

8. Check ‘expand widget template’ box.

9. Search for the following code – <data:post.body/>

10. Now you need to put following code before <data:post.body/>
<b:if cond=’data:blog.pageType == “item”‘> <div id=’googleadsense’> </div> </b:if>

11. Now add the parsed advertising code (generated in step 3) between <div id=’googleadsense’> and </div>

12. Now you need to add a new CSS style for your ad. Search for ]]></b:skin> and place following code before it:

#googleadsense { float:left; /* write ‘right’ to have ads from the right side*/
}

13. Preview your template and save it if it’s alright.

{ 21 comments }

Mr Peraduan January 5, 2009 at 12:09 am

Dont we have to convert the code first? Because new blogger cannot read the custom adsense code and give error msg when i save the template….i think the code converter like at http://www.eblogtemplates.com/blogger-ad-code-converter/ will do the job. :)

Aditya January 5, 2009 at 7:23 am

ya, i mentioned about converting the code using google adsense parser.I have mentioned about this in step 3. Please check

sabaedge January 5, 2009 at 10:22 am

nothing…summa only commented…….

Biju January 28, 2009 at 1:52 am

I tried to do as u mentioned, but faced problems. I searched for <data:post.body/> and found twice. This is the sample code. 

<div class=’post-body’ expr:id=’&quot;post-&quot; + data:post.id’>

 <b:if cond=’data:blog.pageType == &quot;item&quot;’>
        <style>#fullpost{display:inline;}</style>
        <p><data:post.body/></p>
      <b:else/>
        <style>#fullpost{display:none;}</style>
        <p><data:post.body/></p>
   <span id=’showlink’>
          <a expr:href=’data:post.url’>Read more…</a>
        </span>
        <script type=’text/javascript’>
          checkFull(&quot;post-&quot; + &quot;<data:post.id/>&quot;);
        </script>
      </b:if>

Could u plz tell where I should copy the parsed ad.
thankx a million in advance

Aditya January 28, 2009 at 4:43 am

You need to put the code before the first <data:post.body/>. This should solve your problem.

By the way, your blog is good. I really liked the way you write at ‘Tech Trends’.

Please feel free to ask me if you need any further help.

Please do subscribe to my blog if you like reading me.

moih60 January 28, 2009 at 7:12 am

hay..first thanx for ur wonderful tutorial about one of the important thtings in blogging
but it give me an error .i do wat exactly u do but give me that error

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.

i dont now wat to do >>plz help
and again thanx

Aditya January 28, 2009 at 9:05 am

make sure that you do not delete any extra code. Also check to see that you are using parsed adsense.

If you stuck then too, please send me your code via e-mail and I will try to help you. 

stellenangebote berlin February 28, 2009 at 5:06 pm

Gut!

Rohit Kumar April 5, 2009 at 9:39 pm

Parsed adsense code doesn’t violates adsense policy is this true or not please tell because adsense says that you can’t change the code or alter the adsense code

Aditya April 5, 2009 at 10:44 pm

no, parsing adsense won’t violate adsense policy as I myself have used it. Further, you must also note that parsing adsense is fully legal and it doesn’t change your google ad code in any form.

atanim May 9, 2009 at 9:05 pm

I got this error , would appreciate if you help me. Thanks in advance

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.

At the post body part

<script type="text/javascript"><!–
google_ad_client = "pub-2852176345785587";
/* ghost_mouse */
google_ad_slot = "9377085747";
google_ad_width = 468;
google_ad_height = 60;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

at the body part

/** Page structure tweaks for layout editor wireframe */
body#layout #header {
width: 750px;
}
#googleadsense { float:left;]]>

atanim’s last blog post..Restaurant City – Money Cheat WITHOUT using cheat engine

Aditya May 9, 2009 at 10:43 pm

You did not seem to be using adsense parser (as mentioned in step 2) for parsing your ad code. You need to parse the adsense code before you can embed it into your blogger theme. Parsing the code will make it work for you. If then also have some problem, do feel free to contact me at http://scr.im/techravings

Kirk July 11, 2009 at 11:44 pm

Hi, great tutorial, but I have the same problem as atanim. I have parsed the code, and I have checked over all the steps many times, and I don’t see anything wrong. I keep getting the same error message. Any help would be appreciated! THanks

Aditya July 12, 2009 at 3:37 am

Just make sure that whatever code you copy from this page is first pasted on notepad (to avoid formatting) and then copy it from notepad to your blogger theme editor. This should help.

ofw blogger July 21, 2009 at 5:38 am

what about for classic template

Shakaama Live August 6, 2009 at 11:29 pm

I am getting the same error as the others:

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.

___________________________________

Here is my perfectly parsed code, publisher number removed by me on purpose for this post.


<script type="text/javascript"><!–
google_ad_client = "pub-xxxxxxxxxxxxxx";
/* 300×250, created 4/23/09 */
google_ad_slot = "3572617748";
google_ad_width = 300;
google_ad_height = 250;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

You got any idears?

dangerouslydead August 12, 2009 at 12:39 am

Shakaama,

A perfectly parsed code should look something like this

<script type="text/javascript"><!–
google_ad_client = "pub-xxxxxxxxxxxxxx";
/* 300×250, created 4/23/09 */
google_ad_slot = "3572617748";
google_ad_width = 300;
google_ad_height = 250;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Anonymous October 13, 2009 at 2:26 pm

Dear Aditya,
Pls don’t mind , your post is very important to me as I want to use adsense ads in blogger post. But I tried to apply your tricks step by step according to your instruction and failed, because it show me:
“Your template could not be parsed as it is not well-formed. Please make sure that all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.”

muhibbullah October 13, 2009 at 10:26 am

Dear Aditya,
Pls don't mind , your post is very important to me as I want to use adsense ads in blogger post. But I tried to apply your tricks step by step according to your instruction and failed, because it show me:
“Your template could not be parsed as it is not well-formed. Please make sure that all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.”

Aditya @ TechRavings October 13, 2009 at 3:27 pm

Please check if the adsense code is perfectly parsed… coz nothing else should coz problems. Can u give out your parsed code here for me to check?

Aditya October 13, 2009 at 11:27 am

Please check if the adsense code is perfectly parsed… coz nothing else should coz problems. Can u give out your parsed code here for me to check?

Comments on this entry are closed.

blog comments powered by Disqus

Previous post:

Next post: