Growth Engineering

Referral & Affiliate System

Designing for virality: Attribution Logic, First-click vs Last-click, unique code generation, and preventing referral fraud.

High-Level Architecture

The goal is to accurately map a Visitor to a Referrer.

Alice shares Link
/ref/alice123
Bob Clicks
(Cookie Set: alice123)
Bob Signs Up
(Read Cookie)
Attribute Referral
referrer_id = alice

Attribution Models

If a user clicks multiple links (Alice's -> Charlie's), who gets the credit?

Model Logic Pros Cons
Last Click (Standard) Latest referrer cookie overwrites previous. Rewards the closer. Simple to implement. Ignores "awareness" drivers.
First Click First referrer cookie is locked for `N` days. Rewards the introducer. Frustrating for recent influencers.
Window Lookback: Typically 30-day or 90-day cookie expiration.

Fraud Detection

Users will try to refer themselves (Self-referral) to get double rewards.

🚫 Basic Checks
  • Same IP Address?
  • Same Device Fingerprint?
  • Referrer Email == New User Email?
🕵️ Advanced Checks
  • Fuzzy Name Matching ("John Doe" vs "John Doe 2")
  • Payment Method Deduplication (Same credit card?)
  • Velocity Checks (10 referrals in 1 min?)

Summary

  • Unique Codes: Use random strings, allowing users to customize aliases.
  • Cookies: Use 1st-party cookies to persist attribution through sign-up.
  • Fraud: Block the reward, not the sign-up. Let them register, but flag the referral as "Investigate".