Discourse Affiliate

AI-generated summary

The Discourse Affiliate plugin allows forum administrators to monetize their community by automatically converting Amazon links into affiliate links. As an official plugin, it is now bundled with Discourse core, meaning self-hosted administrators must remove it from their app.yml configuration to avoid conflicts. The plugin functions by stripping existing referral links and appending the administrator’s Associate ID (e.g., tag=sams-shop) to new and rebaked posts. It supports various country-specific Amazon programs (US, UK, DE, IN, etc.) via separate site settings.

Key technical details include:

  • Rebaking: Changes only apply to new posts by default. To update historical posts, administrators must run a full post rebake using the rake posts:rebake command. Users have reported issues where rebaking failed to update old posts or incorrectly identified other plugins.
  • Installation: Users attempting to install via theme methods may encounter errors; the plugin must be installed as a core component or via the standard plugin installation guide.
  • OneLink: Questions arise regarding whether separate IDs are needed for each country or if the US ID suffices when Amazon OneLink is enabled.

Community feedback highlights several feature requests and limitations:

  • Link Handling: The plugin currently struggles with short URLs like amzn.to or amzn.eu, as the affiliate tag is often stripped during redirection. AJ_Quick developed a private plugin to resolve this by resolving redirects and replacing the final URL with a direct Amazon link containing the correct tag.
  • Compliance: AJ_Quick suggests adding an automatic disclaimer notice at the bottom of posts containing affiliate links to ensure compliance with US and Canadian laws.
  • Generalization: TroyTime and Richie suggest extending the plugin to support other affiliate networks and custom URL processors beyond just Amazon.
  • Support: Official support, bug reports, and feature requests should be posted in the respective categories on Meta Discourse, tagged with affiliate.
:discourse2: Summary Discourse Affiliate Allows the creation of Amazon affiliate links, and can help you monetize your Discourse forum. When users create links and other users click through those links and buy products from Amazon (or another supported affiliate), they earn referral fees.
:open_book: Install Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.

Features

List of countries where the Amazon Associates program is operational

Amazon.co.uk Associates Program
http://associates.amazon.co.uk/gp/associates/join/main.html

Amazon.de Associates Program
Amazon Sign In

Amazon.fr Associates Program
http://partenaires.amazon.fr/gp/associates/join/main.html

Amazon.it Associates Program
https://programma-affiliazione.amazon.it/

Amazon.ca Associates Program
Amazon Sign-In

Amazon.co.jp Associates Program
アソシエイト・セントラル

Amazon.es Associates Program
https://afiliados.amazon.es/

Amazon.in Associates Program
Amazon Sign-In

Amazon.br Associates Program
https://associados.amazon.com.br/

Amazon.com.mx Associates Program
https://afiliados.amazon.com.mx/

Amazon.cn Associates Program
https://associates.amazon.cn/join

Sign up and read more about the Amazon Associates program at https://affiliate-program.amazon.com/

Configuration

This plugin strips out all referral links in posts and replaces them with your Amazon Associates ID or other supported affiliate ID.

:mega: This change will only affect new and future posts. To have the change affect all existing posts, you will need to do a full post rebake once you set your affiliate ID.

If you set the Site Setting affiliate amazon com to say sams-shop, when people link ANYTHING from amazon.com the plugin will auto append tag=sams-shop and strip out all the existing referral links.

So for example:

https://www.amazon.com/Dragon-Quest-Echoes-Elusive-Age-PlayStation/dp/B07BP3J6RG/

Will be auto converted to:

https://www.amazon.com/Dragon-Quest-Echoes-Elusive-Age-PlayStation/dp/B07BP3J6RG/ref=br_asw_pdt-5?tag=sams-shop

Site Settings

  • affiliate enabled: Enable the Affiliate plugin.
    If you change this, you must rebake all posts with: rake posts:rebake.

  • affiliate amazon com: Your amazon.com (United States) Associates ID. The links will be transformed only for all amazon.ca links using the value entered here.

You will see many more settings such as affiliate amazon co jp, affiliate amazon com au, affiliate amazon ca, enter your Associate ID depending on which country programs you have registered for.

Run Tests

Run bundle exec rake plugin:spec["discourse-affiliate"]

CHANGELOG

TODO

Extras

Last edited by @david 2025-07-22T13:13:11Z

Check documentPerform check on document:
35 Likes

Is it possible to add support for amzn.eu links to this? :thinking:

Eg:

https://amzn.eu/d/4c3852b

Currently redirects to:

https://www.amazon.co.uk/dp/B0CXJ9GM3G?ref_=cm_sw_r_cso_cp_apin_dp_CDAMFS1FPQXBQEWSKWVE&starsLeft=1

It should be converted to something along the lines of:

https://www.amazon.com/dp/B0CXJ9GM3G/?tag=sams-shop

2 Likes

I recently installed this plugin on our site and it works great for new posts, but running the rake posts:rebake command did not cause historical posts to have their Amazon links updated. Is there some common mistake that my team may be making? What I find odd is that the output he received after running the command mentions a different plugin:

Plugin name is 'GroupInvitation', but plugin directory is named 'group-invitation'
Rebaking post markdown for 'default'
414610 / 414610 (100.0%)e
414610 posts done!

Thanks for any additional guidance you can offer.

1 Like

Hi, did you manage to get this working?

Im getting about.json does not exists or not valid error when trying to install

How are you trying to install?

Usually that error is shown when you try to install a Customization > Plugin like you would install a Customization > Theme or Customization > Theme component. Did you follow the instructions in the install guide linked in the first post?

1 Like

Sorry my mistake! Thanks

2 Likes

Hello, I’m using the Discourse Affiliate plugin and have Amazon OneLink enabled for my affiliate ID XXXXXX-20. Since OneLink automatically redirects users to their local Amazon stores, should I enter my affiliate ID only for affiliate amazon com (USA), or do I need to add it for each country separately?

Thanks for your help!

More info about OneLink
:backhand_index_pointing_down::backhand_index_pointing_down::backhand_index_pointing_down:
https://affiliate-program.amazon.com/resource-center/onelink-launch

:partying_face: This plugin is now bundled with Discourse core as part of Bundling more popular plugins with Discourse core. If you are self-hosting and use the plugin, you need to remove it from your app.yml before your next upgrade.

1 Like

Can we add this in the processor rules?

rules["amzn.in"] = create_amazon_rule("in") if postfix == "in"

Posting links directly into the Topic title doesn’t add the code into the link that is created.

A few things I am interested in about the affiliate plugin.

Would it be possible to also make the plugin inject a notice at the bottom of the post in which Affiliate links appear? In the US and Canada (and I’m sure elsewhere) you are required to have a conspicuous notice near the affiliate link.

I think while it is doing the rebake, it would make sense to automatically insert a distinct message at the bottom of the post that says something to the effect of:

Links in this post may contain affiliate links, which help support our site at no additional cost to you.

That way the site can remain in compliance with local laws.

Another thing I would consider is adding the ability to actually remove existing affiliate links to Amazon and replace them with new versions. There are lots of official link cloakers for Amazon, the most common one is amzn.to It is not possible to just add your tag to the end of an amzn.to url as it is stripped away and replaced by the amzn.to site.

But I believe Discourse has the ability to travel through redirects and actually get to the final link? It would be within the ability of the system to look for these Amzn.to links, get the final Amazon product link it redirects to and then work backwards on the bake to change the overall link to be a direct Amazon link with your new tag built in.

Basically I just found a user had posted several articles with their own affiliate links in them and am now trying to locate them and replace them. :areyoukiddingme:

I’d be happy to help extend the existing plugin’s functionality!

EDIT:

Wrote a private plugin to test the feature. It now works as I intended. As you can see the original plugin (or something else) appended the tag to the amzn.to url, but that doesn’t actually work.

Before:

After:

It replaced it with the actual Amazon link, un-shortened and added the new (though same) affiliate tag.

And I just checked, the user’s posts that had affiliate links have all been removed and replaced with ones that actually support the site rather than enrich the user.

2 Likes

This plugin would be immensely more valuable if it worked with custom urls (more than just amazon)

Most forums are niche and most niches have a handful of small businesses with affiliate programs.

I’d be happy to provide affiliate knowledge as assistance, but I don’t code anymore