close



  在部落格文章之間插入Google Adsense 廣告,相信一定會比固定在文章頭或者文章結尾、側欄的廣告來得吸引目光。但是目前Blogger平台並沒有提供如此的功能服務,為了在文章與文章之間插入Adsense 廣告、實現這樣的理想筆者Joey可是費了一般功夫才成功的..。

  如何在Blogger文章插入廣告呢?首先相信大家都已經有Blogger平台的網誌帳號,及已經取得Google的Adsense發佈商的帳號資格,接著進入部落格Blogger範本之中的『編輯HTML』。

 <b:loop values='data:posts' var='post'>

1. 利用搜尋找到程式碼如上,並在後方新增語法 index='i' 後如下:

<b:loop values='data:posts' var='post' index='i'>

2. 接著在<b:loop values='data:posts' var='post' index='i'>後方置入語法及google adsense程式碼

<b:if cond='data:i == 2'>

&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;ca-pub-******&quot;;
google_ad_host = &quot;pub-******&quot;;
/* ****** */
google_ad_slot = &quot;2563825192&quot;;
google_ad_width = 728;
google_ad_height = 90;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;//pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;

</b:if>



3. 大功告成!
  點開首頁後,Google Adsense廣告便會顯示在第三篇文章之前。如果 i = 0 為第一篇文章之前,依此類推。


修改程式前記得先備份..!

<b:loop values='data:posts' var='post'>...</b:loop>
一般用於首頁列出文章使用,可將廣告至於此內。

index='i'
i為 迴圈的位置標記。

<b:if cond='data:i == 2'>
當位置標記i等於2的時候才會show出這裡的內容。
</b:if>



以上為筆者自己嘗試出來的成果,單純筆記使用如果寫得不夠詳細請多包涵。
arrow
arrow
    全站熱搜

    Yoshinocat 發表在 痞客邦 留言(0) 人氣()