Discourse Advertising Plugin (Ads)

:discourse2: Summary Discourse Advertising allows the set up of advertisements on Discourse
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-adplugin
:open_book: Install Guide How to install plugins in Discourse

:warning: AD-BLOCKERS If you are running an ad-blocker in your browser or through a vpn, the contents of your /admin/plugins page may be blanked out. Disabling your adblocker, using an incognito tab, or whitelisting your site should prevent this issue.

Features

This is the officially supported Discourse ad plugin. Install and configure it to start serving ads on your Discourse forum.

The plugin supports the following ad platforms :

Configuration

Setting up House Ads

If you don’t want to use an external ad platform, but want to show your own ads, then House Ads are for you! Define your ads by going to the Admin section of your Discourse forum, and go to the Plugins section. On the left, you should see a link called “House Ads”.

Begin by creating your ads. Give each a short descriptive name and enter the html for each. Style them using a custom theme (Admin > Customize > Themes). Lastly, click the Settings button in the House Ads UI and choose which of your ads to show in each of the ad slots. The ads will start showing as soon as you add them to slots.

Configure Ads For Your Advertisement Platform

  • Navigate to the Admin section in your Discourse forum.
  • Click on Settings and a left vertical navigation bar should appear.
  • Choose your advertisement platform.
    • House Ads - if you want to create and serve ads from your Discourse instance.
    • Adsense - if using Adsense as your advertisement platform.
    • DFP - if using the DoubleClick for Publishers advertisement platform.
    • Carbon Ads - if using the Carbon Ads advertisement platform.
    • AdButler - if using the AdButler advertisement platform.
Input Your Details
  1. Add in your publisher ID - your publisher ID can be obtained from your ad platform and can also be found in your ad tag (see pictures below).
  2. Choose your trust level from the dropdown box. This will only display ads to users with a certain level of trust. For more details about trust levels go to the Plugin Features heading.
  3. Get the Advertisement Tag from your Ad Platform - see the images below to see what a tag looks like.
  4. Add parts of your ad code to Discourse’s site settings for the locations you wish your ad to appear. Refer to image for your ad platform to where parts of your ad tag should go. For more detail about where the ad will appear
  5. Choose Your Ad Size - this is the same size that you’ve put into your ad provider to create your ad. Go to the Plugin Features heading to see a list of supported Ad sizes.
Adsense Advertisement Tag to Discourse’s Site Settings

First, add the contents of your ads.txt file to your Discourse ads txt site setting. Then copy the following values to your Discourse settings:

DoubleClick for Publishers’ Advertisement Tag to Discourse’s Site Settings

Amazon Affiliates’ Advertisement Tag to Discourse’s Site Settings

Only for Product Link and Banner Ads.

Carbon Ads Script Tag to Discourse’s Site Settings

AdButler Ads Zone URL to Discourse’s Site Settings

:warning: This plugin only support AdButler “Standard Zones”. Text and VAST are not supported.

If you browse to a zone in the AdButler admin, then you can find the Publisher ID (PPPPPP) and the Zone ID (ZZZZZZ) in the URL of your browser’s address bar:

https://admin.adbutler.com/?ID=PPPPPP&p=textadzone.view&zoneID=ZZZZZZ

Configure the ads in Admin > Settings > AdButler. Enter the publisher id in the “adbutler publisher id” setting, and enter the Zone IDs in the different zone id settings as desired.

By default, ads are assumed to be size 728 x 90, or 320 x 50 in mobile view. To use different size ads, customize using CSS in your site’s theme. Override the following CSS:

.adbutler-ad { width: 728px; height: 90px; } .adbutler-mobile-ad { width: 320px; height: 50px; }

View Your Ad

Once you’ve configured your settings and your advertising platform has ads that are ready to serve, navigate to the page where you’ve inputted for the location and you should see ads.

Plugin Features

Available Locations for Ad Display

The following are available locations along with a description and an image showing their location within Discourse to display ads for all platforms.

Location Name Description
Topic List Top Ad will appear at the header of Discourse homepage
Topic Above Post Stream Ad will appear in the header of all Discourse forum topics
Topic Above Suggested Ad will appear in the footer above suggested topics of all Discourse forum topics
Post Bottom & Nth Post Ad will appear on the stipulated nth post within a topic. So if you have 5 posts in a topic and you want the ad to display after on the 2nd post, put 2 in ad_platform_nth_post_code .

Trust Levels

You can use the ad_platform_through_trust_level dropdown to disable ads for users above a certain trust levels. As a guide, choosing:

  • 0 shows ads to users that are not logged in.
  • 1 shows ads to users that are not logged in, and to new and basic users.
  • 2 shows ads to members as well, but not to regulars and leaders.
  • 3 shows ads to everyone, but not to leaders.
  • 4 shows ads to everyone including leaders.

To find more about trust levels in Discourse, refer to Discourse’s posts on trust levels

Personal messages

By default, ads won’t be shown in personal messages. To enable ads in personal messages, use the “no ads for personal messages” setting.

Groups

To give some users an ad-free experience, put the users in groups and add those groups to the “no ads for groups” setting.

Note that the Visibility in the group settings needs to be at least Group owners, members, moderators to ensure users who are part of the group can see that the group exists. If the Visibility of the group is more restrictive, the setting “no ads for groups” will be ignored and the ads will be visible to members of the group.

Categories

To disable ads in certain categories, add them to the “no ads for categories” setting. Also consider using the “no ads for restricted categories” to disable ads in all categories that have read access restrictions.

Tags

Individual topics can have ads disabled by using tags, and entering those tags in the “no ads for tags” setting. This is useful if some topics violate ad network policies.

:discourse2: Hosted by us? This plugin is available on our Standard, Business, and Enterprise plans. Advertising | Discourse - Civilized Discussion

Last edited by @MarkDoerr 2024-11-29T17:13:18Z

Check documentPerform check on document:
78 Likes

A post was split to a new topic: How can I add the advertising code of other advertising services?

Support for Ad blocking recovery (AdSense)

Adsense added ad blocking recovery service which works quite well

Problem is if we have subscriptions or patrons it doesn’t know that and so it annoys them. Could we consider adding optional support for this tag(s) so that it can be enabled / disabled based on groups? :pray:

It does require a special Tag

1 Like

Recently after updating my forum to latest version, some of my users are getting a JS syntax error, it looks like it’s coming from the discourse ad plugins, specifically the house ad:

The content security policy guidance is outdated. What’s the latest?

Thanks for the reminder that I needed to update the OP. Done. :slight_smile:

We implemented a strict-dynamic CSP a while back and you shouldn’t need to do any further setup.

We’d recommend removing https: or unsafe-inline unless you need them for some specific reason, as they do not provide any protection against XSS vulnerabilities.

1 Like