AdSense Responsive Ads

:warning: IF YOU ARE RUNNING AN AD BLOCKER RIGHT NOW YOU WILL HAVE A VERY BAD TIME TRYING TO SET THIS UP! TURN IT OFF BEFORE PROCEEDING DOWN THIS PATH! You’ve been warned. :dragon:

Google AdSense offers the option to show ads with a size of Google’s choice using the responsive ad size option.

:warning:

Note that responsive ads are an all-or-nothing option. You can’t limit the height and width of them. They will cause jumpy behaviour when scrolling within a topic.

It is recommended to use fixed size ads instead.

Defining your AdSense ad units

Simply define your ad unit(s) in AdSense using the responsive option:

It can take a few hours before AdSense has any inventory to show in the ad unit, so it’s useful to define some fallback creative in the “If no ads available” field to verify that the ad unit is working and to see which ad sizes AdSense is choosing.

Once you create the ad unit, it will show up in your ad units list with a numbered ID. You’ll need the ID to enter in Discourse.

Discourse Settings

On your Discourse instance, go to Admin > Settings > AdSense. Enter your publisher ID as usual (the number after pub-), enter the ad unit ID in the location(s) where you want it to appear, and choose “responsive” as the size.

Current limitations require you to set a very permissive policy using the content_security_policy_script_src site setting. See below:

Controlling Ad Sizes

There is no way to control responsive ad sizes anymore due to changes made by Google. See discussion later in this topic.

@neil thanks a million. This simplifies things wonderfully for using Adsense in a multi-device world. Great work.

A simple like is not enough - this is a massive improvement. Only thing missing is that desktop view ads are not resized if the window is. I have no idea how feasible this is and it is quite an outlier use case. Mobile view scales nicely when the device is rotated 90-degrees.

So great work!

P.S. Server cost whiners - if you have traffic, this can roughly compensate the costs.

Ads that are already rendered won’t be re-sized since we would need to ask the AdSense javascript library to re-fetch the ad (and I don’t remember there being any way to do that). The next time an ad unit is rendered, it should pick up the new view size anyway.

Glad it’s working out well for you!

@neil I would need a little hand holding with this.

On mobiles (with full HD screens or better) the responsive setting has started to increasingly show large square banners in the top banner positions. This drops the majority of the content below the fold.

I tried mocking around based on your CSS example but could not nail it. I would like to halve the top banner height, making it a large mobile banner (320x100). How could I achieve that?

What CSS did you use, and how did you add/enable it? Which ad units are you trying to limit the height?

It should be this if you want it to be 100px height of the ad unit above the topic lists:

:warning:

This doesn’t work anymore

.adsense-topic-list-top.adsense-responsive {
  height: 100px;
}

Thanks, I’ll give that a try tomorrow or later this week.

Been using the responsive ads for a full year, since my earlier praise in this thread. For some reason the large square ad format has increased popularity as time went by. Originally I got the large mobile banners, but now more squares.

Thanks, I’ll report back later.

@neil

Now I just realized that the code you pasted above was identical to the earlier. The reason I had issues implementing was that for some reason it does not work correctly in the Chrome Inspector / Mobile mode (the ad remains square and topics flood over it), but now when I implemented it again and verified on real devices, the results look as expected.

I’ll ask my community to verify this to get some device diversity.

Update: Well, our community is the best and had already spotted layout breakage. This happens on some Android devices at least.

I can see square ads in Chrome on Android too, and sometimes banner ads. I don’t see it underneath the topic list content though… Which devices are people seeing layout problems?

Also, I don’t see the CSS to control height, which would prevent the square ads.

Sony XZ, Honor 7 and OnePlus 5T were used by those who reported. The screen capture was taken with the Sony phone.

And you want to allow square ads, which is why you didn’t add the custom css with height?

@neil 改めて、このプラグインを提供していただきありがとうございます。この単一コンポーネントは、他の資金源なしで運営されている私たちのコミュニティにとって、成否を分ける重要な機能です。

この機能がプラグインに追加されて以来、Responsive設定でAdSenseバナーを運用してきました。しかし最近、Responsive広告が正常に動作しなくなってきました。意図したユーザー体験を損なう(ファーストビューに広告が多すぎる)大きな広告ユニットが表示されるようです。また、iPhone SEでは広告が大きすぎて、画面を横持ちにしない限り、画面に大きな空白が表示されてしまいます。

設定を確認したところ、広告サイズがマルチ選択オプションになっていることに気づきました。ここで検索を試みましたが、このマルチ選択機能が実際にどのように動作するか(複数のサイズを選択した場合、どの広告サイズがいつ表示されるか)に関する情報が見つかりませんでした。

複数のサイズを選択した場合、広告ユニットはそれらを均等に行き来して表示されます。例えば、同じ広告枠でバナー広告と正方形の広告を交互に表示させることができます。

表示されている広告の高さに関する問題については、このトピックの最初の投稿で示されているように、広告枠に高さのルールを追加してみてください。

:warning:

これはもはや機能しません!

余談ですが、レスポンシブ要素のサイズ制御がうまく動作しませんでした。9月にGoogleがレスポンシブ単位を更新したことに気づきました。

最大の高さ/幅の指定がプラグインに追加されれば素晴らしいだけでなく、固定サイズオプションが不要になるかもしれません。開発ロードマップで検討する価値があるかもしれません。

これは既に可能です。このトピックの最初の投稿にある**(オプション) 広告サイズの制御**セクションをご覧ください。

余談ですが、レスポンシブ要素のサイズ制御はうまく動作しませんでした

しかし、それが目的ではありませんでした。何度か試してみましたが、何らかの理由で(私たちのシナリオでは)そのままだと動作しません。

もし動作していれば、現在かなりごちゃごちゃしているプラグイン設定ビューを簡素化できたはずです。

何を提案されているのかはわかりませんが、この記事では、レスポンシブ広告がコンテナを無視できるようになったと書かれているようです。

…レスポンシブ広告ユニットは、現在、内包する HTML 親コンテナ(例:<div>)のサイズを変更できるようになりました。これにより、パブリッシャーのページ上のあらゆる広告サイズに自動的に適応できます。

なお、レスポンシブ広告ユニットが正しく機能するためには、固定または制限された高さを持つコンテナ内に配置してはなりません。

なるほど。:frowning:

レスポンシブ広告の高さを制限したい場合は、レスポンシブ広告コードを変更する必要があります…

<ins class="adsbygoogle" style="display:inline-block;min-width:400px;max-width:970px;width:100%;height:90px"

つまり、以前はコンテナと CSS でやっていたことを、今度はインラインスタイルで行い、Google に「あらゆる広告サイズに自動的に適応」させる(それが何を意味するかはともかく)ということです。

しかし、彼らの例を見ると、CSS を使用してもまだ機能するようです:@ljpp この記事をご覧ください:

レスポンシブユニットの最大幅や高さを制御するために CSS を試してみなかったのでしょうか?2 つの記事は矛盾していますので、もしかすると彼らの例は古くなっているかもしれません。


広告の通知が表示されていますが、広告自体は表示されていません。

広告が表示されるべき場所に「advertisement」という単語しか表示されないのはなぜですか?これが私の設定です!Screenshot_20191209-180110|281x500, 50%

こんにちは。広告に関する、繰り返し発生し非常に厄介な問題についてフィードバックをいただきたく、この投稿をしています。

モバイル環境では、ページ内のすべての要素が読み込まれた後でも、投稿が上下に「跳ねる」(適切な表現が見つかりませんが)ことがよくあります。これにより、特定の投稿を読むのが非常に難しくなります。画面が投稿の位置に固定されず、再度表示しようとするたびに跳ねてしまいます。これは広告が原因だと考えています。広告がない場合はこの問題は発生しないからです。設定はすべて適切に行っており、Discourse のレスポンシブ広告と Adsense のレスポンシブ広告コードが対応しています。

この挙動に心当たりのある方はいますか?
Adsense が広告の高さを常に「決定」しようとしていることが原因でしょうか?