# Affiliate link functions - rewrite

**URL:** https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606
**Category:** Feature
**Created:** [September 9, 2024, 9:29am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606 "2024-09-09T09:29:08Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 9, 2024, 9:29am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/1 "2024-09-09T09:29:08Z")

</div>

Hello all,

Thinking of getting a forum, possible ways to monetise with display ads. Also looking at affiliate.  
If any user posts a link are we able to inject the affiliate link - destination remains the same, just that we add our own tracking link.

thanks

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [September 9, 2024, 12:57pm UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/2 "2024-09-09T12:57:10Z")

</div>

A quick search turns up some plugins that you may find useful:

- [Discourse Affiliate](https://meta.discourse.org/t/discourse-affiliate/101937)
- [Discourse Advertising Plugin (Ads)](https://meta.discourse.org/t/discourse-advertising-plugin-ads/33734)

If you’re unfamiliar with how to install plugins, this guide can help: [Install plugins on a self-hosted site](https://meta.discourse.org/t/install-plugins-on-a-self-hosted-site/19157)

good luck!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 9, 2024, 6:19pm UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/3 "2024-09-09T18:19:23Z")

</div>

If you’re talking about for something other than Amazon, I have a theme component that does it in [what I thought to be a strange way](https://www.literatecomputing.com/blog/2023-08-08-discourse-affiliate-linker/). It would need to be changed to work for anything other than the home page for the site.

> [@Discourse-affiliate-linker](https://meta.discourse.org/t/discourse-affiliate-linker/320824):
>
> information_sourceSummary Replace links with affiiliate linkseyeglassesPreview [Discourse-affiliate-linker - Plugins and Themes - Literate Computing Dashboard](https://dashboard.literatecomputing.com/t/discourse-affiliate-linker/950)hammer_and_wrenchRepository [GitHub - literatecomputing/discourse-affiliate-linker: Replace links with referral links · GitHub](https://github.com/literatecomputing/discourse-affiliate-linker)questionInstall Guide [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Rep…

You’re welcome to fork it, or, if you have a budget, contact me and I’ll consider either modifying the above component or making an other one for you (depending on which makes more sense).

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [September 9, 2024, 6:20pm UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/4 "2024-09-09T18:20:35Z")

</div>

There is also

> [@eBay EPN Affiliate Link Generator](https://meta.discourse.org/t/ebay-epn-affiliate-link-generator/292012):
>
> information_sourceSummary eBay EPN Affiliate Link Generatorhammer_and_wrenchRepository [GitHub - ScottMastro/discourse-ebay-affiliate: Discourse theme component to inject eBay affiliate links · GitHub](https://github.com/ScottMastro/discourse-ebay-affiliate)questionInstall Guide [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) This theme component replaces eBay links with affiliate links and discloses when this has happened Requirement: you will ne…

---

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 10, 2024, 6:35am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/5 "2024-09-10T06:35:40Z")

</div>

thanks, yes, saw ones for amazon but this is for any link so what would happen:

1. user posts link
2. system checks if it’s one of our active affiliate partners
3. link is amended

---

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 10, 2024, 6:37am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/6 "2024-09-10T06:37:04Z")

</div>

thanks looking for something more custom - not ebay/amazon - more any outgoing sites that we have as partners which could be dozens of sites

---

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 10, 2024, 7:04am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/7 "2024-09-10T07:04:12Z")

</div>

Thanks Jay, possibly something like this.  
I’m in discovery phase for a new brand/site and forum a key component.  
we would have dozens of affiliate partners.  
so a user may post with a root domain [Example.com](http://Example.com)  
or a deep link [Example.com/link/link/etc](http://Example.com/link/link/etc)

in every link case we would want to cross check to see if it’s an affiliate partner - and if so change the link to an affiliate (tho still on face of it, showing the clean link - for various reasons, but we’d be clear that we have affiliate links to user).

what do you think

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 10, 2024, 2:26pm UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/8 "2024-09-10T14:26:48Z")

</div>

As I said, the theme component that I linked would need to be modified to work for deep links–it was specifically developed **not** to work for deep links. As a theme component, it works in the browser. This has advantages of not needing to rebake posts when affiliates are added, removed, or changed. You’re welcome to contact me or ask in #Marketplace.

A plugin could be better since it wouldn’t be re-writing the URLs in the browser, but it would be more complicated since it would require rebaking posts when a change was made affecting those posts. Maybe $1000 +/- $500?

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [September 11, 2024, 4:00am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/9 "2024-09-11T04:00:43Z")

</div>

As @pfaffman said his component or the eBay affiliate component that @Moin linked would be good candidates as a starting point for a custom #Customization > Theme component to meet your needs.

---

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 11, 2024, 10:34am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/10 "2024-09-11T10:34:02Z")

</div>

Thanks so much Jay! Appreciate you coming back and detailing things.  
Great it all sounds pretty doable. I’m scoping out the whole biz model for it. If we go ahead, I’ll absolutely contact you.

---

<div class="post-metadata">

### Author: ![bernardyoghurty](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bernardyoghurty](https://meta.discourse.org/u/bernardyoghurty)
#### Post date: [September 11, 2024, 10:34am UTC](https://meta.discourse.org/t/affiliate-link-functions-rewrite/325606/11 "2024-09-11T10:34:50Z")

</div>

thanks Dan
