{"id":672,"date":"2026-04-03T17:00:00","date_gmt":"2026-04-03T22:00:00","guid":{"rendered":"https:\/\/dev.tolinku.com\/?p=672"},"modified":"2026-03-07T03:33:14","modified_gmt":"2026-03-07T08:33:14","slug":"referral-link-generation","status":"publish","type":"post","link":"https:\/\/tolinku.com\/ko\/blog\/referral-link-generation\/","title":{"rendered":"\ucd94\ucc9c \ub9c1\ud06c \uc0dd\uc131: \uae30\uc220 \uad6c\ud604"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Referral link generation looks straightforward on the surface. You give a user a URL, they share it, and you track who came from whom. In practice, the implementation has a lot of moving parts: unique code generation, URL structure decisions, deep link compatibility, mobile app routing, and fraud resistance. Get any of these wrong and you end up with broken attribution, duplicate rewards, or a system that falls apart when users share links across different surfaces.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide covers the full technical picture for building referral link generation that works reliably.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Core Components of a Referral Link<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A referral link needs to carry at minimum:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A way to identify the referrer (user ID, unique code, or both)<\/li>\n<li>A destination (where the new user lands after clicking)<\/li>\n<li>Attribution metadata (campaign, channel, context)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest form is a URL parameter:<\/p>\n\n\n\n<pre><code>https:\/\/yourapp.com\/signup?ref=abc123\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This works for basic web flows. It breaks down the moment the user:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clicks on mobile and your app is installed (should open the app, not the browser)<\/li>\n<li>Clicks on mobile and your app is not installed (needs to land correctly after install)<\/li>\n<li>Shares via a surface that strips query parameters (some messaging apps do this)<\/li>\n<li>Copies the link and pastes it somewhere that truncates it<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">A production referral system needs deep link-aware URLs that handle all of these cases.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Server-Side vs Client-Side Generation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Client-side generation<\/strong> (building the link in the browser or app) is tempting because it is fast and requires no API call. The problem is that you cannot validate anything client-side. A user can manipulate the referral code before sharing, create synthetic links with arbitrary codes, or generate links for other users&#39; IDs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Server-side generation<\/strong> is the correct approach. When a user requests their referral link, your server:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Authenticates the request<\/li>\n<li>Looks up (or generates) the user&#39;s referral code<\/li>\n<li>Creates the link with verified attribution data<\/li>\n<li>Returns the URL<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This adds a round trip but gives you control over the data that ends up in the link.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Generating Unique Codes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The referral code is the identifier that ties a click back to a referrer. A few approaches:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Deterministic from user ID.<\/strong> Hash the user ID with a secret salt and take a substring. Fast, no storage needed, but codes are predictable if someone discovers your algorithm.<\/p>\n\n\n\n<pre><code class=\"language-javascript\">const code = crypto\n  .createHmac(&#39;sha256&#39;, process.env.REFERRAL_SECRET)\n  .update(userId)\n  .digest(&#39;base64url&#39;)\n  .slice(0, 8)\n  .toUpperCase();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Random with storage.<\/strong> Generate a random code and store the user-to-code mapping. More flexible (users can regenerate their code, you can revoke codes), requires a database lookup on every click.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Sequential with obfuscation.<\/strong> Use a numeric ID but encode it with something like <a href=\"https:\/\/hashids.org\/\" target=\"_blank\" rel=\"noopener\">Hashids<\/a> so it does not look sequential. Avoids enumeration attacks while keeping codes short.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For most applications, random codes stored in a <code>referral_codes<\/code> table are the right choice. They are short enough to share verbally (important for some use cases), easy to look up, and straightforward to revoke.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">URL Structure Options<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Query Parameter Approach<\/h3>\n\n\n\n<pre><code>https:\/\/yourapp.com\/signup?ref=ABC123\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pros: simple, works everywhere, easy to parse.\nCons: can be stripped by some platforms, looks like tracking to privacy-conscious users, does not work for mobile app deep linking without additional handling.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Path-Based Approach<\/h3>\n\n\n\n<pre><code>https:\/\/yourapp.com\/r\/ABC123\nhttps:\/\/yourapp.com\/invite\/ABC123\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pros: cleaner, less likely to be stripped, easier to make memorable.\nCons: requires server-side routing for every code, slightly more complex to implement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Subdomain Approach<\/h3>\n\n\n\n<pre><code>https:\/\/ABC123.yourapp.com\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Rarely worth the infrastructure complexity for referral links specifically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Deep Link-Aware URLs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The best approach for mobile apps is to use a link management system that generates URLs which:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Redirect to the App Store or Google Play if the app is not installed<\/li>\n<li>Open the app directly if it is installed (via Universal Links on iOS or App Links on Android)<\/li>\n<li>Pass the referral code through the install so it is available when the app first opens (deferred deep linking)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">See the <a href=\"https:\/\/tolinku.com\/docs\/concepts\/deferred-deep-linking\/\">Tolinku deep linking docs<\/a> for a full explanation of how deferred deep linking works. This is the mechanism that makes referral attribution work after an app install.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Embedding Referral Data in Deep Links<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When you create a deep link for a referral, you embed the referral code in the link&#39;s metadata. The link management system preserves this data through the entire flow, including through the App Store redirect and install.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A referral link might carry:<\/p>\n\n\n\n<pre><code class=\"language-json\">{\n  &quot;referralCode&quot;: &quot;ABC123&quot;,\n  &quot;referrerId&quot;: &quot;user_789&quot;,\n  &quot;campaign&quot;: &quot;friend-invite&quot;,\n  &quot;channel&quot;: &quot;in-app-share&quot;,\n  &quot;createdAt&quot;: &quot;2026-03-04T10:00:00Z&quot;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the new user opens your app for the first time (or clicks the link if the app is already installed), your SDK reads this metadata and you can:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pre-fill the signup form with context (&quot;You were invited by Sarah&quot;)<\/li>\n<li>Attribute the new user to the referrer immediately<\/li>\n<li>Trigger the reward flow automatically<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Using the Tolinku API for Referral Link Generation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\"https:\/\/tolinku.com\/wp-content\/uploads\/2026\/03\/platform-platform-referrals.png\" alt=\"Tolinku referral program dashboard with analytics\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/tolinku.com\/docs\/developer\/api-reference\/referrals\/\">Tolinku&#39;s referral API<\/a> handles the link creation, deep link generation, and attribution tracking in one call. Here is a basic server-side implementation:<\/p>\n\n\n\n<pre><code class=\"language-javascript\">\/\/ Generate a referral link for a user\nasync function generateReferralLink(userId, options = {}) {\n  const response = await fetch(&#39;https:\/\/app.tolinku.com\/v1\/referrals\/links&#39;, {\n    method: &#39;POST&#39;,\n    headers: {\n      &#39;Authorization&#39;: `Bearer ${process.env.TOLINKU_SECRET_KEY}`,\n      &#39;Content-Type&#39;: &#39;application\/json&#39;,\n    },\n    body: JSON.stringify({\n      referrerId: userId,\n      campaign: options.campaign || &#39;default&#39;,\n      channel: options.channel || &#39;unknown&#39;,\n      metadata: {\n        userId,\n        ...options.metadata,\n      },\n    }),\n  });\n\n  const data = await response.json();\n  return data.url; \/\/ e.g., https:\/\/go.yourapp.com\/r\/ABC123\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/tolinku.com\/docs\/user-guide\/referrals\/setup\/\">referral setup guide<\/a> walks through configuring your Appspace for referral tracking, including setting up the attribution window and reward triggers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a full walkthrough of link structure and parameters, see the <a href=\"https:\/\/tolinku.com\/docs\/user-guide\/referrals\/referral-links\/\">referral links documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Unique Codes vs URL Parameters: Which to Use<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is not really an either\/or decision. Most production systems use both:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>URL path or subdirectory<\/strong> contains the human-readable or shareable form: <code>\/r\/ABC123<\/code><\/li>\n<li>The <strong>underlying link<\/strong> contains richer metadata that does not need to be in the URL itself<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">What you should avoid is putting sensitive data in the URL directly (like the user&#39;s internal database ID as a plain integer). Even if your codes are random, treat them as semi-public and do not design your system so that knowing someone&#39;s referral code reveals anything sensitive about them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Handling Link Expiration and Revocation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Referral links generally should not expire for standard programs. A user shares their link in a tweet, it gets picked up six months later, and you want it to still work. However, you may want to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Revoke codes<\/strong> for users who have been banned or who violated terms<\/li>\n<li><strong>Expire campaign-specific links<\/strong> that were generated for a limited-time promotion<\/li>\n<li><strong>Rotate codes<\/strong> on user request (some users want to reset their referral history)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Build your code storage with a <code>status<\/code> field (active, revoked, expired) and a <code>campaign_id<\/code> foreign key. When a link is clicked, validate both the code status and the campaign window before attributing the referral.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tracking Attribution After Click<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The click itself is only the first step. You need to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Record the click with timestamp, referral code, and metadata (user agent, IP hash for fraud checks)<\/li>\n<li>Store a cookie or device fingerprint so you can match the click to a later signup<\/li>\n<li>When the new user signs up, look up pending attribution and create the referral record<\/li>\n<li>Trigger the reward flow<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For mobile installs, step 2 is handled by the deep link system rather than cookies. The Tolinku SDK reads the deferred deep link data on first app launch and passes it to your attribution callback.<\/p>\n\n\n\n<pre><code class=\"language-swift\">\/\/ iOS SDK - read referral data on first launch\nTolinku.shared.getReferralData { data in\n    guard let referralCode = data?[&quot;referralCode&quot;] as? String else { return }\n    \/\/ attribute the install to this referral code\n    YourAPI.attributeInstall(referralCode: referralCode)\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Short Links for Sharing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Long URLs with query parameters or encoded metadata are impractical for manual sharing (SMS, verbal communication, printed materials). Generate short links as the user-facing format and resolve them server-side to the full attribution URL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most link management platforms handle this automatically. The short link (<code>go.yourapp.com\/r\/ABC123<\/code>) redirects to the full destination with all attribution metadata intact.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the full picture on how Tolinku handles referral attribution end to end, see the <a href=\"https:\/\/tolinku.com\/features\/referrals\">referral features page<\/a> and the <a href=\"https:\/\/tolinku.com\/docs\/user-guide\/referrals\/rewards-and-attribution\/\">rewards and attribution docs<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Solid referral link generation comes down to a few decisions made correctly:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generate codes server-side with validation, not client-side<\/li>\n<li>Use deep link-aware URLs for mobile apps so attribution survives the install<\/li>\n<li>Store codes with status and campaign metadata so you can revoke and expire them<\/li>\n<li>Keep the user-facing URL short and clean, while the underlying link carries full attribution data<\/li>\n<li>Hook into your SDK&#39;s deferred deep link callback for mobile attribution<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These choices compound. A referral system built on top of reliable link infrastructure is much easier to extend with fraud prevention, tiered rewards, and analytics than one built on simple query parameters and cookies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Related reading: <a href=\"https:\/\/tolinku.com\/blog\/building-referral-programs-that-work\/\">Building Referral Programs That Work<\/a>, <a href=\"https:\/\/tolinku.com\/blog\/deferred-deep-linking-how-it-works\/\">Deferred Deep Linking: How It Works<\/a>, <a href=\"https:\/\/tolinku.com\/docs\/use-cases\/referral-programs\/\">Tolinku Referral Use Cases<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ucd94\ucc9c \ub9c1\ud06c\ub294 URL \ub05d\uc5d0 \ucffc\ub9ac \ud30c\ub77c\ubbf8\ud130\ub9cc \ubd99\uc778\ub2e4\uace0 \ub05d\ub098\uc9c0 \uc54a\uc544\uc694. \uc774 \uac00\uc774\ub4dc\uc5d0\uc11c\ub294 \uc11c\ubc84\uc5d0\uc11c \ub9c1\ud06c\ub97c \uc0dd\uc131\ud558\ub294 \ubc29\ubc95, URL \uad6c\uc870, \ub525 \ub9c1\ud06c\uc5d0 \ucd94\ucc9c \ub370\uc774\ud130\ub97c \ub123\ub294 \ubc29\ubc95, \uadf8\ub9ac\uace0 Tolinku API\ub85c \ucd94\ucc9c \ub9c1\ud06c \uc2dc\uc2a4\ud15c\uc744 \uc644\uc131\ud558\ub294 \uacfc\uc815\uc744 \ub2e8\uacc4\ubcc4\ub85c \uc0b4\ud3b4\ubd10\uc694.<\/p>","protected":false},"author":2,"featured_media":3447,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"Referral Link Generation: Technical Implementation","rank_math_description":"Learn how to generate referral links the right way: server-side generation, URL structures, deep link embedding, unique codes vs parameters, and the Tolinku API.","rank_math_focus_keyword":"referral link generation","rank_math_canonical_url":"","rank_math_facebook_title":"","rank_math_facebook_description":"","rank_math_facebook_image":"https:\/\/tolinku.com\/wp-content\/uploads\/2026\/03\/og-referral-link-generation.png","rank_math_facebook_image_id":"671","rank_math_twitter_title":"","rank_math_twitter_description":"","rank_math_twitter_image":"https:\/\/tolinku.com\/wp-content\/uploads\/2026\/03\/og-referral-link-generation.png","footnotes":""},"categories":[13],"tags":[62,28,20,142,45],"class_list":["post-672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-growth","tag-api","tag-attribution","tag-deep-linking","tag-mobile","tag-referrals"],"_links":{"self":[{"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/posts\/672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/comments?post=672"}],"version-history":[{"count":1,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":673,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/posts\/672\/revisions\/673"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/media\/3447"}],"wp:attachment":[{"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/media?parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/categories?post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tolinku.com\/ko\/wp-json\/wp\/v2\/tags?post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}