# Other websites in the Official Discourse Affiliate plugin

**URL:** https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819
**Category:** Feature
**Tags:** affiliate
**Created:** [26. Juli 2016 um 13:01 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819 "2016-07-26T13:01:59Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [26. Juli 2016 um 13:01 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/1 "2016-07-26T13:01:59Z")

</div>

For everyone, there is an [**Official Discourse affiliate plugin**](https://github.com/discourse/discourse-affiliate) allowing you to automatically add your amazon ID in each links that will be published on your forum.

I want to use this plugin to add other websites that offer Affiliate program. I tried [another one](https://meta.discourse.org/t/discourse-affiliate-insert-affiliate-code-amazon-automatically-to-links/19585) few weeks ago but it broke the polls in preview for some reason.

Anyway, I tried working on the official one tonight even if I don’t have a lot of knowloedge.

Here is my example : I want to add the french website LDLC. The tag to add on each page is something like this : `#52325a32` (this is not my real tag)

There is three links that we usually share :

- `http://ldlc.com/#52325a32` (homepage, I can live without this one)
- `http://www.ldlc.com/b-06b841d7761b563e.html#52325a32` (a cart - useful when we “build” a PC for our users)
- `http://www.ldlc.com/fiche/PB00200087.html#52325a32` (a product page)

I managed to make the easy one work (the product page) with a clever copy/paste because it looked a lot like the amazon one (all caps and numbers, 10 characters). Here is my take on this : [https://github.com/iunctis/discourse-affiliate/blob/master/assets/javascripts/lib/discourse-markdown/affiliate.js.es6](https://github.com/iunctis/discourse-affiliate/blob/master/assets/javascripts/lib/discourse-markdown/affiliate.js.es6)

But when I tried something else to make all three types of links work, it didn’t work.

I tried multie things like this one : `const LDLC_ASIN_EXTRACTOR_REGEX = /\/[A-Za-z0-9/+]/i;` to allow different characters even slash (and I deleted the `/fiche` part in the href). It added the tag but the link was broken.

If anyone has a solution, it’d be great 😚

There is nothing urgent here, I can wait.

Thanks for reading ✌

(edit : I deleted and re-fork the officiel plugin, I had too many messed up commits, I wanted to start from scratch again. So I had to edit some parts of my post)

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [28. Juli 2016 um 03:17 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/2 "2016-07-28T03:17:24Z")

</div>

Yatta!

I did it. But It was painful 😅

I think I had a good regex (at least test regex websites seemed to think so) but when I used something like this in the ASIN regex `(\/[A-Za-z0-9_\/-]*)` it always captured `/www` and not the url after `ldlc.com/`.

To succeed, I had to use `{5,}` in my ASIN regex. This way, it had to ignore the `/www`. It’s ugly, the experts here will cry while facing this awful coding. But hey… it works 😆

There must be a better way to do it tho, if someone has an idea, I can still try it..

Anyway I can move on to the next website I want to add. It will be a lot easier than this one.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [28. Juli 2016 um 05:53 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/3 "2016-07-28T05:53:20Z")

</div>

From the way you say /www was matching, I think you might want to write a regex that explicitly considers them. It’s hard for me to be sure, though, since I’m not familiar with where this gets used.

Here’s what _I suspect_ will work for you:

`(\/[w.]*ldlc.com\/[A-Za-z0-9_\/-]*)`

It’s not clear if backslash escaping the slash is needed. If the one in the first post with a / in the character class worked, then I don’t think you need any of the backslashes.

---

<div class="post-metadata">

### Author: ![rriemann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rriemann/32/115238_2.png) [@rriemann](https://meta.discourse.org/u/rriemann)
#### Post date: [28. Juli 2016 um 07:36 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/4 "2016-07-28T07:36:51Z")

</div>

I suggest to use [http://rubular.com/](http://rubular.com/) to test the regex. You can enter in the text box all three examples you want to have supported and maybe some links that should not be matched. Rubular should use the same Regex engine. It’s ruby as well.

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [28. Juli 2016 um 11:21 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/5 "2016-07-28T11:21:40Z")

</div>

Thanks!

I’ll check these to see if I can make my part of the plugin better 🙂

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [29. Juli 2016 um 15:15 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/6 "2016-07-29T15:15:58Z")

</div>

Just added support for [ldlc.com](http://ldlc.com) affiliation program 🌺

[https://github.com/discourse/discourse-affiliate/commit/085a59c0988d5bc66035dfee2493d346738c5426](https://github.com/discourse/discourse-affiliate/commit/085a59c0988d5bc66035dfee2493d346738c5426)

---

<div class="post-metadata">

### Author: ![gingerman](https://avatars.discourse-cdn.com/v4/letter/g/47e85d/32.png) [@gingerman](https://meta.discourse.org/u/gingerman)
#### Post date: [29. Juli 2016 um 15:56 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/7 "2016-07-29T15:56:37Z")

</div>

@zogstrip Is there a way to use the plugin for Native advertising ? (Chosen topics/post from our own forum used as AD)..That will really helpful 😉

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [29. Juli 2016 um 15:57 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/8 "2016-07-29T15:57:31Z")

</div>

Great job! Can’t wait to try it tonight.

It seems way easier to add affiliates now. I’ll try in a few days for another website, if it works and if it’s interesting I’ll make a pull request.

edit : LDLC works fine. Way better than my modifications. Amazing

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [29. Juli 2016 um 17:27 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/9 "2016-07-29T17:27:15Z")

</div>

Thanks @zogstrip !

Here are others you could add:

- [https://www.digitalocean.com/](https://www.digitalocean.com/)\* =\> [AI-Native Cloud | DigitalOcean](https://www.digitalocean.com/?refcode=fdc7761ea776)
- [https://www.moo.com/](https://www.moo.com/) =\> [Refer a Friend or Business to MOO | MOO (United States)](https://www.moo.com/share/7xz8pg) (only work if root link)
- [https://pipedrive.com/](https://pipedrive.com/) =\> [Sales CRM & Pipeline Management Software | Pipedrive](https://pipedrive.com/taf/human-coders) (only work if root link)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [29. Juli 2016 um 17:31 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/10 "2016-07-29T17:31:22Z")

</div>

I will need the docs for each one of this if possible.

I tried adding DO, but they don’t seem to use that anymore (they use referral links like this `https://m.do.co/c/12345abdc`).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [29. Juli 2016 um 17:44 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/11 "2016-07-29T17:44:37Z")

</div>

I would avoid adding a bunch of random sites here. Only if the site is a “top 50” website for now.

---

<div class="post-metadata">

### Author: ![CamilleRoux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/camilleroux/32/119575_2.png) [@CamilleRoux](https://meta.discourse.org/u/CamilleRoux)
#### Post date: [29. Juli 2016 um 17:47 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/12 "2016-07-29T17:47:07Z")

</div>

Here is the one for Moo : [Refer a Friend or Business to MOO | MOO (United States)](https://www.moo.com/us/refer-a-friend/) and the one of Pipedrive : [Log in](https://humancoders.pipedrive.com/settings/invites) (you should be logged)  
For Moo and Pipedrive, it’s not a param, it’s just a link. I think we should only replace link to root, or even each mention of Moo and Pipedrive.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [29. Juli 2016 um 17:48 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/13 "2016-07-29T17:48:43Z")

</div>

I asked the doc to see if I can extract a pattern allowing me to write a generic one and then adding a new affiliation platform would just be a matter of configuration.

---

<div class="post-metadata">

### Author: ![anon36484860](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon36484860](https://meta.discourse.org/u/anon36484860)
#### Post date: [19. November 2017 um 13:11 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/14 "2017-11-19T13:11:42Z")

</div>

Digging out the thread here.

Are there any plans to add a feature that enables users to add their own custom sites + regex rules?

---

<div class="post-metadata">

### Author: ![p0fi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/p0fi/32/261315_2.png) [@p0fi](https://meta.discourse.org/u/p0fi)
#### Post date: [22. Januar 2022 um 19:51 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/15 "2022-01-22T19:51:22Z")

</div>

Ich möchte dieses Thema auffrischen!

Gibt es Pläne, in naher Zukunft eine Möglichkeit zum Hinzufügen benutzerdefinierter Domains und Regeln bereitzustellen?

---

<div class="post-metadata">

### Author: ![physixfan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/physixfan/32/184201_2.png) [@physixfan](https://meta.discourse.org/u/physixfan)
#### Post date: [12. Oktober 2023 um 07:20 UTC](https://meta.discourse.org/t/other-websites-in-the-official-discourse-affiliate-plugin/47819/16 "2023-10-12T07:20:57Z")

</div>

Einverstanden. Es ist besser, es den Forenadministratoren zu ermöglichen, weitere benutzerdefinierte Domains hinzuzufügen.  
Oder vielleicht können Sie Temu offiziell hinzufügen? Es ist jetzt eine riesige Seite.
