How to put Adsense in New Blogger
Tuesday, March 06, 2007
ŠŠŠŠWhen Blogger transformed into the new XML based interface I was quite apprehensive of moving into the new blogger template. I found it damn dificult to customize the template according to my wishes but now I am gradually getting hold of the new template. And now onwards I will post some hacks I have made in new blogger. It is time for putting the adsense code in new blogger.
The easiest method to put adsense code in new blogger is by creating page elemet for adsense or html/java script at the top and bottom of blogpost element as shown in picture. But the main
problem in this technique is that the adsense ad will appear at the top and bottom of the page and not in each individual post.
Now we will do something so that adsense ad will appear at the beginning and end of each posts. And that can be done by adding the code by directly modifying the html (rather XML) code of the template. But when you will insert the adsense code directly inside XML code of the blogger you will receive an error that reads something like this:Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
The above error means that the adsense code is not a standardized XML format. So we need to modify the code (But google does not allow the modification of adsense code, do not worry..google only tells that minor edits on Google Adsense Code for Blogger Beta/XML are allowed as long as the resulting Adsense Code generated by Blogger is exactly the same as given from Google Adsense Code Generator. So as long as find the same adsense code as the adsense code generator generated by viewing the page source where the adsense code appears you are not violating the TOS.). In XML, <, >, " and " are not recognized. So we need to replace these character with their valid XML notation as shown in figure below:
Once you create the adsense code from the adsense code generator, you have to make the above changes, which can be done with the use of a notepad (by find and replaced command) or with a html parser.
Now in the following steps we will put the modified adsense code where we want it to appear:
1. Go to your blogger dashboard and click on Layout.2. Click on Edit HTML3. Click on Expand Widget Templates4. Now put the modified adsense code at the place as shown the following figure:
The final result will be shown in your blog like this: