Fire after your referral backend confirms the redemption — not on code submission. Don't pass the code, the referrer's user ID, or the redemption reward.
▸Install the Swift (iOS) SDK
// Package.swift
dependencies: [
.package(url: "https://github.com/respectlytics/respectlytics-swift.git", from: "3.0.0")
]
// Or via Xcode → File → Add Packages → paste the URL above.
The SDK ships only via Swift Package Manager. CocoaPods and Carthage are not published — fewer integration paths means fewer surfaces to keep audited.
▸Initialize Respectlytics in Swift (iOS)
import Respectlytics
@main
struct MyApp: App {
init() {
Respectlytics.configure(appKey: "<YOUR_APP_KEY>")
}
var body: some Scene { WindowGroup { ContentView() } }
}
Call configure once at app launch — typically in your App struct's init. No Info.plist keys are required: the SDK does not call ATTrackingManager and does not request the IDFA, so NSUserTrackingUsageDescription should NOT be added.
▸Track the event in Swift (iOS)
import Respectlytics
func redeemReferral(code: String) async {
// The code is a credential — passes to api, never to track.
do {
try await referralApi.redeem(code: code)
Respectlytics.track("referral_redeem")
} catch {
Respectlytics.track("referral_redeem_failed")
}
}
Failure event is useful for UX diagnosis — typos, expired codes, and rate-limiting all surface as referral_redeem_failed.
✦Privacy & implementation notes
Referral codes are short-lived credentials that grant credit. They belong in your referral backend with proper one-time-use enforcement and audit logging — not in product analytics. Respectlytics's API rejects free-text fields, so the code never reaches the analytics layer even if a teammate tries to add it.
The referrer→referree graph is high-cardinality, mutable (refunds void credits), and tied to reward payouts. It is an operational data store, not a product-analytics signal. Respectlytics's role is the rate of redemptions as a product-engagement signal; the graph is your referral system's job.
Apple rejected approximately 3% of apps in 2024 for incorrectly omitting NSUserTrackingUsageDescription when ATT was required by the SDKs they shipped. Respectlytics doesn't trigger ATT. The corollary is also true: do not add the key on Respectlytics's account — its presence implies you track across apps, even if your code never calls requestTrackingAuthorization.
Internally the Swift SDK uses Swift Concurrency: events are queued in an actor-isolated buffer (RAM-only), flushed on a 30-second timer and on UIApplication.willResignActiveNotification. Force-quit before flush drops queued events — by design. There is no UserDefaults or file backing.
⇋How this compares to other analytics SDKs
| Referral redemption event | Firebase Analytics | Mixpanel | Respectlytics |
|---|---|---|---|
| Referral code stored | Common | Common | Rejected by API |
| Referrer user ID stored | Yes | Yes | Never |
| Referree user ID stored | Yes | Yes | Never |
| Reward amount stored | Recommended | Recommended | Out of scope |
| Redemption *rate* by country / platform | Yes | Yes | Yes |
❓Frequently asked questions
How do we know who referred whom without storing the graph?
Your referral backend stores the referrer-referree relationship — that's its job, with the credit-attribution logic that drives reward payouts. Respectlytics tells you whether the redeem-step is working at the aggregate level; the per-user graph is a referral-backend concern.
Can we still compute viral coefficient (k-factor)?
From your referral backend, yes — count of redemptions per referrer over a window is exactly what your backend has. Respectlytics tells you the redemption rate (sessions emitting referral_redeem over sessions emitting referral_code_entered); k-factor is a different question, answered by a different system.
Should we differentiate redemption reasons (organic vs paid)?
If you have a small fixed set of campaign types, distinct event names: referral_redeem_organic, referral_redeem_paid_campaign_a. For high-cardinality campaign IDs, your referral backend's reporting is the right tool.
What if the redemption fails (invalid code, expired)?
Distinct event name: referral_redeem_failed. The rate of failures relative to attempts is a UX signal — high failure rates often indicate copy-paste issues or expired-link problems.