AdSense Responsive Ads

advertising

(Neil Lalonde) #1

Google AdSense offers the option to show ads that fit within the dimensions of their container at the time they will be rendered using the responsive ad size option. The official Discourse Ad Plugin supports AdSense responsive ad sizes.

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.

That’s it!

(Optional) Controlling Ad Sizes

You can have full control over the dimensions of the responsive ad units because AdSense looks at the size of the container when choosing the size of ads to show.

Using a custom theme, you can use CSS to set the size of each ad slot. For example, to limit the height of the ads that show above topic lists:

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

How to activate google adsense
(Kenny DuBose) #2

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


(ljpp) #3

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.


(Neil Lalonde) #4

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!