wanichanの日記

ちょっとした技術メモ。Microsoft中心。Webサイト管理等にまつわるネタ、サイトの更新情報等を発信中。最終版はwanichan.comに掲載していきます。

Google AdSenseのレスポンシブリンクの仕組み

新しい広告ユニットの作成の際、広告サイズを[レスポンシブ]にすれば、レスポンシブの広告と、レスポンシブリンクの両方出てくるんですね。

レスポンシブWebデザイン対応のサイトを運営している人は、これだけでもOKな気がします。

f:id:wanichan:20160119103955p:plain

で、生成されたコード見てみますと、仕組みはとてもシンプル。

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- link -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx"
data-ad-format="link"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

 data-ad-format の値が link になっていればリンク広告になるんですね。

他に data-ad-format のパターンはこんな感じ

  • data-ad-format="auto" --- 自動サイズの普通の広告
  • data-ad-format="rectangle" --- レクタングルの普通の広告
  • data-ad-format="horizontal" --- 横長サイズの普通の広告
  • data-ad-format="vertical" --- 縦長サイズの普通の広告

詳しくはヘルプ参照してみてくださいです。