web analytics

How to add adsense ad code BEFORE the CONTENT in blogger template?

Before the content is one of the recommended ad positions I have already mentioned in the post 5 Best Ad Positions to Increase Adsense Revenue. In this post, we will see how we can add adsense ad code before the content of each post and page. We will do this in the blogger template so that we don’t have to do this for each post and page.

How to Add Adsense Ad Code Before the Content:

Login to your blogger account and go to the Template page using the left side menu and then click on the Edit HTML button.

This will bring up the template code editor. Now click on the code editor and press Ctrl+F and search for <data:post.body/>.

PLEASE NOTE: It can be that you have multiple <data:post.body/> in your template. If you do not know which one is the actual one working then please read the following post to find out or simply watch the following video tutorial first.

Okay, so if you have found the actual <data:post.body/> in your template then before that tag write the following
<b:if cond='data:blog.pageType in {&quot;item&quot;,&quot;static_page&quot;}'>
<div id='beforeContentAd' style='float: left; margin: 0 10px 10px 0; padding: 0; text-align: center;'>
<!-- Your Ad Code Here -->

Here, you have to replace <!– Your Ad Code Here –> with your adsense ad code.

Remember, this is XML. So you have to escape your ad code for XML. To do this, you can use this XML Escape/Unescape tool. Just copy your ad code and place it in the textarea in the tool and click ESCAPE, then copy the escaped code and paste here at <!– Your Ad Code Here –>

I recommend you to use a 300×250 or 336×280 square ad in this place, as those have performed well for me. You can optionally use a responsive ad too.

Also, as you can see, I have placed a wrapper around the ad code with ID #beforeContentAd with style to float left and 10px margin at right & bottom.

If you want to have the ad to right then change float to right and margin to ‘0 0 10px 10px’

If you want to have a responsive ad then put margin to top and bottom and float to none.

You can optionally use height and width with the wrapper div too.

As you are using ads in content, it is highly recommend that you blend the style of the ad with the style of your content.

Please follow and like us:
Pin Share
Follow by Email
Scroll to Top