A referral program rests on one design choice: the referrer's identity must be explicit in your own data, not inferred from a browser. The cleanest way is to give every advocate a unique code or ID inside their referral URL, capture that identifier when the friend arrives, and carry it through to signup or purchase. This is the simplest and most durable method, and it works even when cookies are blocked the Extole cookieless tracking guide. Salesforce describes the same mechanic from the program side: referral software uses the referring customer's unique identifier to track who is referring, who is accepting the referral, and which incentive applies the Salesforce referral guide.
Build the link in two layers. The first layer is your own code, for example ?ref=AB12CD, where AB12CD is a short opaque token that maps to one row in a referrers table. Never put an email address or a sequential user ID in the URL; a sequential ID lets anyone enumerate your customer base, and an email address leaks personal data into browser history and referrer headers.
The second layer is standard UTM parameters so analytics tooling sees the click as a campaign. Google's documentation lists the parameters (utm_source, utm_medium, utm_campaign, utm_id, utm_content and others) and recommends always using source, medium and campaign the Google Analytics URL builder documentation. UTM parameters are unaffected by third-party cookie changes and are typically well integrated into analytics platforms the AdRoll UTM guide. A referral link for a customer named in your database as referrer AB12CD, shared by email, looks like this:
https://www.example.com/join?ref=AB12CD
&utm_source=referral&utm_medium=referral_link
&utm_campaign=refer_a_friend&utm_content=email_share
Two rules keep this clean. First, keep values lowercase and separated by dashes, and enforce one documented naming convention across the team; inconsistent source naming splinters traffic data and makes analysis hard the utm.io best practices checklist. Second, never tag internal links with UTMs; those parameters are for incoming traffic from external sources the AdRoll UTM guide. A referral link that a logged-in user clicks inside your own app should pass the code, not a UTM string, or your campaign reports fill with self-referrals.
One practical warning about codes: make them long enough to be unguessable and short enough to survive a screenshot. Six to eight characters from a mixed alphabet is workable. A friend who types a code by hand is a real case, so validate on input, normalize case, and reject any code that does not resolve to an active referrer.



