Official Advertising / Ad Plugin for Discourse

Hi :smile:,

There is now an officially endorsed advertising plugin ready for use. You can install it and start serving ads on your discourse forum.

Supported Ad Platforms :

You can download the officially endorsed Advertising plugin here and start serving ads to your Discourse forum.


5 posts were split to a new topic: Ad Plugin ads showing too often

I was able to get responsive ads in AdSense working on desktop. An example of a responsive ad that filled the width:

I’ll do mobile next. (For some reason the plugin hard-codes a size of 320x50 on mobile for all AdSense ads…)

But DFP… :cry:

Support for truly responsive ads doesn’t exist. You always needs to specify the size of ads in two places: your javascript via defineSlot, and in your DFP ad unit definitions. There are ways to kinda add support for responsive ads, but it means your javascript needs to define a list of all the ad sizes you want to allow at which viewport widths. Surely you should be able to set this list when you define the ad units in DFP, so I don’t understand why you need to define them again in your javascript…

So, the solution for DFP going forward is one of these:

  • Keep adding more values to the lists of ad sizes
  • Remove the lists and change the settings so you enter the arbitrary dimensions you want. (Not sure how to migrate existing DFP users to new settings…)

Getting error: Failed to load resource: the server responded with a status of 400 ()

How to resolve this?

1 Like

400 Bad Request can indicate that your DFP publisher ID is wrong. In your DFP console, go to Admin > Global Settings > All network settings and find the number in “Network code”. Mine is 9 digits long.

Also it could mean the ad size that DFP is trying to serve is larger than the ad unit you’ve defined in your Discourse settings. DFP refuses to serve ads that will be cropped.


To do responsive properly with JS and defineSlot, can you please provide the following @neil? Thanks in advance!

  1. List of Discourse viewport widths
  2. List of ALL the different URLS where the ads can appear.
    For example, “dfp topic list top code desktop” & “dfp mobile topic list top code” appear at “/” and “/c” (from what I can tell but I’m 100% sure). We need this so we can create “zones” to map our tags in the JS properly.
  • dfp topic list top code
  • dfp mobile topic list top code
  • dfp topic above post stream code
  • dfp mobile topic above post stream code
  • dfp topic above suggested code
  • dfp mobile topic above suggested code
  • dfp post bottom code
  • dfp mobile post bottom code

@Brock_Busby I think all the widths are in the main mixins.scss file.

All the urls is all the topic list pages. (e.g., /latest, /unread, etc.), and any topic page (/t/topic-slug/123).

I’m curious what you’re going to do to get it working. :thinking:


Appreciate it @neil ! We are going to attempt to do proper responsive using JS like on our regular site
I’ll come back once we try it out on our test server.

1 Like

Does it work with Native In-Feed and In-Article Ad blocks?

Status don’t change for Native type blocks…

1 Like

Status 400 (bad request) is coming from AdSense, and means you need to wait until Adsense approves your new ad units or has some ads to show. It’s hard to say why Adsense is rejecting the request.


A post was split to a new topic: Using DFP to show house ads

this reply is a great resource, I wish I found this weeks ago. I’d suggest to create a #howto out of this, I’d be happy to contribute as I keep on learning DFP on my own.

Wow…this works.
Thanks @Steven and @pfaffman for the tips.

1 Like

One more question:
Do we have any plans to support ‘In-feed’ ads?

These ads are basically meant to be shown WITHIN the post content and they really perform well than ads outside the post reading area.

Do a search, there are feature requests and requests in #marketplace for them to be added, no one seems interested enough to do it though.


what’s the extent of amazon CPM support and what would the plugin author’s best practice suggestion be for what fall-back code to use? What are experiences with Amazon CPM and responsiveness?

1 Like

Hi @cpradio
Not sure if you are interested in adsense customization on discourse, but, i wanted to share this update.

We no longer need to use the Discourse Adsense plugin to get ads inside the post!
The adsense AUTO ADS can do it in neat and pretty way.

See here:

This can be done using the Adsense Auto ads with just a single code that can be placed inside the theme customization head tag.
Google is using AI (artificial intelligence) to find the right point to display the ads automatically on any page on your website. No need to worry about type of placement of ads now.
Its all automatic!

Check this link for verifying the display of ads.


That’s very cool Anil! I’ve been navigating around your site and eventually wasn’t seeing any ads in any topics. I wonder if AdSense is making that decision, or if there’s a problem with Auto Ads on single-page apps like Discourse.


i just read more about this yesterday… it’ll be interesting to see how intelligent the placement really is…

1 Like

Yes, i guess that could be a problem at this time.
I have been trying to test the pages and it looks like it loads ads on full page load only.

I will test it for couple of days on Discourse installation to see the AD metrics and then take a decision with respect to keeping it or move back to plugin.

On a side note, I have tested it on wordpress installation and AUTO ADS are indeed loaded separately on each new post there pretty well. The AD placement varies on each page though.
Sometimes, only 1 AD is shown and other times up-to 3 automatically at different places on the page.