Having taught thousands of students to build serverless applications via my online courses and workshops, I felt it was time to kick-start an affiliate program to boost sales. Affiliates would receive 50% of the revenue and get a 15% discount code for their audience. It feels like a good deal but I would need a way to track these affiliate sales.
To my surprise, most popular affiliate tracking software options on the market turned out to be quite expensive. Starter packages typically range between $100/month to a whopping $1000/month.
I’m not confident I can generate enough affiliate sales to justify this level of outlet. More to the point, I want to fail cheaply if things don’t work out.
Why a custom affiliate tracking system?
Currently, I host the AppSync Masterclass [1] and Testing Serverless Architectures [2] on Thinkific [3]. And I use LemonSqueezy for my Production-Ready Serverless [4] workshop.
Both Thinkific and LemonSqueezy support affiliates but they’re not suitable for my needs. Because:
- Thinkific is not a merchant of record, which meant I’m responsible for collecting VATs and reporting them to the relevant countries. Digital tax on online courses is a complex subject [5] and I’m not equipped to deal with it.
- Because of the above, I use Paddle [6] to handle payment processing and they act as the reseller and deal with all matters related to tax.
- Paddle does not allow instructor-led courses on their platform, so I have to use another platform for my workshop. In the end, I chose LemonSqueezy as the payment platform because they are more cost-effective than Gumroad.
- I want to use the same affiliate tracking system for both platforms so an affiliate can see his/her earnings in one place.
Given these challenges with existing platforms, I pondered whether to switch platforms or to develop a custom solution.
- Move from Thinkific. Teachable [7] is the obvious choice. It handles tax collection and has built-in support for affiliates. I wouldn’t need Paddle anymore, but I’d have to import all my existing courses and uproot all my students. Plus, I had already paid for Thinkific for the next 12 months…
- Built a custom affiliate tracking system and see if it’s something worth investing more effort into.
Given the context, it’s evident which path I chose.
The anatomy of an affiliate tracking system
I’ve never built an affiliate tracking system before, so I turned to ChatGPT to find out what it would entail.
The basic ingredients are surprisingly simple:
- A unique URL for each affiliate.
- A cookie to remember which affiliate a user came from.
- A way to be notified when a referred user makes a purchase.
The commercial software would include features such as advanced reporting and fraud detection. Fraud detection would be important if you pay affiliates for clicks. But in my case, it’s a revenue share scheme, so fraudulent clicks are not a concern.
Additionally, students can request a full refund within 30 days as part of my happiness guarantee. So affiliates also cannot cash out purchases made within the last 30 days.
Building the affiliate tracking system
Here’s a snapshot of how I built the affiliate tracking system:
A student visits a course’s homepage through an affiliate URL, such as
productionreadyserverless.com/?affiliateId=314f53f4-9ab5-4a25-b47f-228bb1884b4e
. If anaffiliateId
cookie doesn’t exist already, then one is created with an expiration time of 30 days. This means the first affiliate that refers a student would receive the 50% commission.When the student makes a purchase, a payload including the affiliate ID is passed to either Paddle or LemonSqueezy.
Paddle or LemonSqueezy notifies our REST API via a POST webhook. The payload from step 2. is included in the body of the webhook. The request is handled by a Lambda function, which extracts the payment details (payment platform, order ID, course name, gross and net amounts, timestamp) and saves it in a DynamoDB table. When a student requests a refund, the same webhook notifies our API of these and the previous purchase is cancelled accordingly.
Another Lambda function is triggered by the DynamoDB stream. This function notifies the affiliate (and me) of the sale/refund by email, using the SES service. Yes, this step can be combined into step 3. But I think this is the best reason for using DynamoDB streams [8] – to engineer a distributed transaction out of your architecture.
The affiliate can log into the affiliates’ portal and see his/her commissions. The portal uses the passwordless sign-in flow (with one-time passwords) described in this post [9].
- Once logged in, the portal talks to an AppSync API to fetch the affiliate’s commissions and his/her unique affiliate URLs.
This system is nothing fancy, but it works and ticks all my boxes.
It took less than a day’s work in total and has no running cost as everything is under the free tier.
Moving forward, I aim to incorporate features like analytics reporting – visitors count, commissions over time, etc. and a self-service signup flow. But first, I need to prove that there is an appetite for my affiliate program. After all, that’s the whole idea behind building out this system, it’s so that I can experiment and fail cheaply.
Now, the quest is to find passionate affiliates to collaborate with. If serverless technology excites you as much as it does me, or if you know someone who fits the bill, let’s connect!
Links
- [1] AppSync Masterclass course
- [2] Testing Serverless Architectures course
- [3] My school on Thinkific
- [4] Production-Ready Serverless workshop
- [5] What’s up with digital tax for online courses
- [6] Paddle
- [7] Teachable
- [8] The best reason to use DynamoDB Streams
- [9] Passwordless Authentication made easy with Cognito: a step-by-step guide
The post How I built an affiliate tracking system in a weekend with serverless appeared first on theburningmonk.com.
Top comments (0)