# What’s the best way to add an affiliate / referral program into Weweb apps?

**URL:** <https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895>\
**Category:** Ask us anything\
**Created:** [August 15, 2023, 1:25pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895 "2023-08-15T13:25:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 15, 2023, 1:25pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/1 "2023-08-15T13:25:57Z")

</div>

How do we run affiliate programs / referral programs on apps with Weweb? Is there a recommended app / software? 😃

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 15, 2023, 2:24pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/2 "2023-08-15T14:24:08Z")

</div>

You write to your database based on a query string parameter, nothing fancy really. What functionalities is this refferral supposed to have?

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 15, 2023, 3:32pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/3 "2023-08-15T15:32:47Z")

</div>

How will we integrate this with Stripe so that the affiliates get a commission for every friend they recommended?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 15, 2023, 4:01pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/4 "2023-08-15T16:01:23Z")

</div>

You would count this on backend and then do one time payout based on the database by multiplying it by some logic.

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 15, 2023, 4:14pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/5 "2023-08-15T16:14:32Z")

</div>

Sorry I don’t quite understand. What do you mean by that?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 15, 2023, 4:27pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/6 "2023-08-15T16:27:26Z")

</div>

1. You store the relationships between who invited who via a magic link, by saving the relationships to Xano/Supabase. You can do this by looking at query parameter.
2. You set a dashboard, where people can withdraw, it’s not done automatically, that would be too much hassle for nothing. People indeed are motivated to withdraw, so they won’t mind.
3. When they want to withdraw, you do your magic, either send them money, or something, via your prefferred method. Tax wise I’m not sure where this falls, depends on your country.

---

<div class="post-metadata">

**Author:** ![caffeinatedwes](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/caffeinatedwes/32/625_2.png) [@caffeinatedwes](https://community.weweb.io/u/caffeinatedwes)\
**Post date:** [August 15, 2023, 6:46pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/7 "2023-08-15T18:46:05Z")

</div>

If you don’t have particular functionality where you need to do this from scratch, I recommend using an off-the-shelf tool like [Growsurf](https://growsurf.com/).

However, we’ve developed a referral functionality for a client that needed something more bespoke, following similar logic to what @Broberto mentioned. Then, we used an integration with [Tremendous](https://www.tremendous.com/) to handle global payouts.

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 28, 2023, 1:09pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/8 "2023-08-28T13:09:37Z")

</div>

Ah, I see. This has been very insightful @caffeinatedwes and @Broberto — there’s 2 things I don’t get:

I’m wondering how do we track clicks?

Also, affiliate links usually have a cookie period - how would we implement this?

Thank you both.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 1:10pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/9 "2023-08-28T13:10:19Z")

</div>

Define a click for us please 🙂 You mean how you track users landing on your site?

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 28, 2023, 1:11pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/10 "2023-08-28T13:11:17Z")

</div>

@Broberto Yes! Usually affiliate programs have a dashboard where affiliates can see how many visitors they are driving via their affiliate links. 😊

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 1:12pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/11 "2023-08-28T13:12:39Z")

</div>

> [@Broberto](#):
>
> You store the relationships between who invited who via a magic link, by saving the relationships to Xano/Supabase. You can do this by looking at query parameter.

You append to each link a query string and then work with that

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 28, 2023, 1:13pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/12 "2023-08-28T13:13:54Z")

</div>

Are you talking about the clicks or the cookie period? Not quite understanding ☹

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 1:20pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/13 "2023-08-28T13:20:04Z")

</div>

When you create the affiliate links, you append a query string which will help you identify the user. When the user clicks on the link, it brings him to your page, where you look for the query string, if it exists, you write to your database the relationship, based on the identifier you get from the url string

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 28, 2023, 3:19pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/14 "2023-08-28T15:19:13Z")

</div>

1. Is there a way to track how many visitors visited the link with the ref code? Regardless of whether it’s saved to the database or not. Because some people won’t sign up…

2. What if the referred visitor goes to my sign up page with the ref link, but does not sign up, but later comes back and signs up?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 3:24pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/15 "2023-08-28T15:24:19Z")

</div>

1. You can make a table for that solely, for analytics, and write to both referral, and also visited referral.
2. You could store it as a cookie or something similar and then on signup check for it, or just make people insert the code. Depends on how you want to deliver it.

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 28, 2023, 3:34pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/16 "2023-08-28T15:34:10Z")

</div>

Ah, I see… does this mean that for every visitor to the ref url, I create an additional row in that database table?

Also, how do I store as a cookie?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 28, 2023, 3:47pm UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/17 "2023-08-28T15:47:38Z")

</div>

I think you’ll be fine with localStorage, even though having ability to set a cookie - without custom JavaScript would be cool @aurelie?

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 29, 2023, 9:04am UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/18 "2023-08-29T09:04:19Z")

</div>

@Broberto Hello! I’m trying to do what you suggested above but am running into a slight roadblock — let’s say someone goes to [url.com/ref=RAELYN3847](http://url.com/ref=RAELYN3847)

So the refID is “RAELYN3847”.

How do I store this in a variable, for starters?

Would it be via a “on page load” workflow? & if so, how would I do it? I can’t find the refID in the editor…?

I have created a refID query variable -

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/9775bd2c26ac098faacdc991b5f3074cec2b0c38.png)

Trying to change its value on page load but can’t seem to find a value for it to be changed to?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/b860233f23c144870c3e2eb983f0bc965bbe1d99.png)

Am i on the right track? How do I change refID to what’s in the URL?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 29, 2023, 9:44am UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/19 "2023-08-29T09:44:48Z")

</div>

1. create the variable, in my case it’s **ref**
2. append **?ref=Raelyn** to your URL as shown in the screenshot and reload the page (not only the editor - hard refresh the page)
3. Done

You in theory can check for refs on each page via a saved global workflow, if you wanted to do it like you did with **a slug** /ref=RAELYN, I’m not sure how that would work, you 'd have to create a dynamic page for that.

 ![Screenshot 2023-08-29 at 11.40.46](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/64685188251d3f7a87ac26f93754b2258824d26d.png)

So yeah, I’m also sending some a very nice documentation on the query strings and the URLs in general, as I feel like it might be confusing at first.

> **[What is a URL? - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL#parameters)**
>
> With Hypertext and HTTP, URL is one of the key concepts of the Web. It is the mechanism used by browsers to retrieve any published resource on the web.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [August 29, 2023, 9:49am UTC](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895/20 "2023-08-29T09:49:07Z")

</div>

After that, you can store it however you want it, as I mentioned, you could do a global workflow and call it each time page loads to check if it’s in the string and against your backend.

[Next page](https://community.weweb.io/t/what-s-the-best-way-to-add-an-affiliate-referral-program-into-weweb-apps/3895.md?page=2)
