Creating Short Referrer Links
Generate short, shareable referrer links that enable user-to-user attribution and track app installs from organic referrals.
Version Requirement: This functionality requires SDK version 12.1.1 or higher. Short links remain active for 30 days after creation.
Overview
What Are Short Referrer Links
Short links transform long, parameter-filled Singular Links into compact, secure URLs convenient for sharing via SMS, social media, or in-app invitations.
Create short links dynamically so users can share them with friends to invite them to download and use your app. Each short link tracks the referring user, enabling you to measure viral growth and attribute new installs to specific advocates.
Implementation Requirements
Required Components
Gather these elements before creating a short referrer link:
- Singular Link: A base tracking link that directs users to your app download. See Singular Links FAQ for setup instructions
- Dynamic Parameters: Optional custom parameters to add context to the link. View available options in Tracking Link Parameters
- Referrer Information: Name and ID of the user sharing the link to enable attribution of new installs back to the referrer
SDK Method
createReferrerShortLink
Generate a short referrer link with custom parameters and callback handlers for success and error states.
Method Signature:
Singular.createReferrerShortLink(
String baseLink,
String referrerName,
String referrerId,
JSONObject parameters,
ShortLinkHandler handler
)
Parameters:
- baseLink: The original Singular tracking link URL
- referrerName: Display name of the referring user
- referrerId: Unique identifier for the referring user
- parameters: JSONObject containing additional dynamic parameters (optional)
-
handler:
Callback interface with
onSuccessandonErrormethods (required)
ShortLinkHandler defines two abstract
methods (onSuccess(String link) and
onError(String error)), so it is not
a Kotlin SAM interface. Always implement it as an object expression
(Kotlin) or anonymous class (Java) with both methods defined. A
null handler or an uninitialized SDK
causes the call to be dropped silently — verify
Singular.init() has run before
invoking this method.
onError may fire synchronously
before any network request when validation fails (for example, an
invalid base link). Implement defensive null checks in your callback
so it can run on either the calling thread or a background thread.
Usage Example
Create a short link with custom parameters and implement sharing logic in the success callback.
import org.json.JSONObject
import org.json.JSONException
// Create custom parameters for the link
val params = JSONObject()
try {
params.put("channel", "sms")
params.put("campaign_id", "summer_promo_2025")
params.put("referral_type", "friend_invite")
} catch (e: JSONException) {
Log.e("ShortLink", "Error creating parameters: ${e.message}")
}
// Generate the short referrer link
Singular.createReferrerShortLink(
"https://sample.sng.link/D52wc/cuvk?pcn=test", // Base Singular Link
"John Doe", // Referrer name
"user_12345", // Referrer ID
params, // Custom parameters
object : ShortLinkHandler {
override fun onSuccess(shortLinkURL: String) {
Log.d("ShortLink", "Generated: $shortLinkURL")
// Share the short link via Android Share Sheet
val shareIntent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_TEXT,
"Join me on this awesome app! $shortLinkURL")
}
startActivity(Intent.createChooser(shareIntent, "Share via"))
}
override fun onError(error: String) {
Log.e("ShortLink", "Error creating link: $error")
// Handle error - retry or show user feedback
Toast.makeText(
applicationContext,
"Failed to create share link. Please try again.",
Toast.LENGTH_SHORT
).show()
}
}
)
import org.json.JSONObject;
import org.json.JSONException;
// Create custom parameters for the link
JSONObject params = new JSONObject();
try {
params.put("channel", "sms");
params.put("campaign_id", "summer_promo_2025");
params.put("referral_type", "friend_invite");
} catch (JSONException e) {
Log.e("ShortLink", "Error creating parameters: " + e.getMessage());
}
// Generate the short referrer link
Singular.createReferrerShortLink(
"https://sample.sng.link/D52wc/cuvk?pcn=test", // Base Singular Link
"John Doe", // Referrer name
"user_12345", // Referrer ID
params, // Custom parameters
new ShortLinkHandler() {
@Override
public void onSuccess(final String shortLinkURL) {
Log.d("ShortLink", "Generated: " + shortLinkURL);
// Share the short link via Android Share Sheet
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"Join me on this awesome app! " + shortLinkURL);
startActivity(Intent.createChooser(shareIntent, "Share via"));
}
@Override
public void onError(final String error) {
Log.e("ShortLink", "Error creating link: " + error);
// Handle error - retry or show user feedback
Toast.makeText(
getApplicationContext(),
"Failed to create share link. Please try again.",
Toast.LENGTH_SHORT
).show();
}
}
);
Implementation Best Practices
Error Handling
Implement robust error handling in the
onError
callback
to manage network failures, invalid parameters, or server issues.
- Retry Logic: Implement exponential backoff for transient network errors
- User Feedback: Display clear error messages when link creation fails
- Fallback Option: Provide alternative sharing methods (e.g., share the full Singular Link if short link creation fails)
-
Validation:
Verify parameters before calling
createReferrerShortLinkto catch issues early
Tracking and Analytics
Leverage referrer information to build viral loops and measure organic growth.
Best Practice: Use consistent referrer IDs that match your internal user identification system. This enables you to:
- Attribute new installs to specific referring users
- Reward users for successful referrals
- Track viral coefficient and K-factor metrics
- Identify your most valuable brand advocates
Link Expiration
Plan for the 30-day link lifecycle in your sharing strategy.
Important: Short links expire after 30 days. For long-term campaigns or persistent share features, generate new short links periodically or use the full Singular Link as a fallback.
Common Use Cases
In-App Referral Programs
Enable users to invite friends directly from your app with personalized referral links.
- Reward System: Track referrals and reward users for successful friend signups
- Social Sharing: Integrate with Android Share Sheet for SMS, WhatsApp, email, and social media
- Personal Invites: Include referrer name in the shared message for personalization
User-Generated Content
Create shareable links when users generate content they want to share with others.
- Content Attribution: Track which content drives the most app installs
- Creator Recognition: Attribute new users to content creators for gamification
- Campaign Tagging: Add dynamic parameters based on content type or category
Event Invitations
Generate unique links for event invitations that track which attendees bring new users.
- Event Context: Include event ID and details in link parameters
- Attendee Tracking: Measure viral spread from event to event
- Network Effects: Identify events with the highest conversion rates