Tuesday, 3 June 2014

How put AdSense Ad middle or anywhere of blog post

First Step

To put your Adsense ad in the middle or any where you must to know your adsense code. If you have an active AdSense account and you know your publisher ID. Then you have nothing to wary just follow step.
Go to adsense-generator.com Select
  1.        Ad type-  ad unit (what you want, Text and  image ads -preferable ),
  2.         select corner style ( any of that you select does not matter )
  3.        Client number – Put AdSense publisher Id
  4.        Format – which type ad  you want at the post
  5.        Color – Select color combination
  6.        Pallete – Default Google pallete

Then click save number, after that you show in right side of scene you AdSense code are ready. Copy that code.
  IF you face any problem so that I past adsense code below you have to change yellow marked place but remember ad width, hight and ad format  must be google standard size.

<script type="text/javascript">
google_ad_client = "pub-1234567812345678";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "0000FF";
google_color_link = "FFFFFF";
google_color_text = "000000";
google_color_url = "008000";
</script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

Second Step

This step is more important so be careful.
Go to blogger Template >> click on Edit HTML >> when it open find tag <data:post.body/> by search(ctrl+f)or manually find.
<data:post.body/>tag you may find several time but you need find second on or if you can’t see changes test the third one.
Now what to do? Replace <data:post.body/> tag with code below:
<div expr:id='"adsmiddle1" + data:post.id'></div>
<div style="clear:both; margin:10px 0">
<!—Replace this line with AdSense code -->
<div expr:id='"adsmiddle2" + data:post.id'>
<script type="text/javascript">
var obj0=document.getElementById("adsmiddle1<data:post.id/>");
var obj1=document.getElementById("adsmiddle2<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);}
Then replace adsense code which you get first step with <!—Replace this line with AdSense code --> line in the code which color green above the code.
Now save template.

Then open your post and show AdSense are display in post. 

No comments: