Respectlytics Respect lytics
Menu
Flutter Referral redeem Privacy-first

How to track referral redemption in Flutter without personal data

Referral redemption is the closing event of a viral loop — and the place where most analytics SDKs build referrer-graph data structures by default. Respectlytics helps developers avoid collecting personal data in the first place: in Flutter, redemption is one named event when the referral apply succeeds, with no payload. The referrer-referree graph stays in your referral backend, where it has a legitimate purpose. Below: how to instrument, why the code stays out, and how to size loop performance.

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 Flutter SDK

yaml Respectlytics
# pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
  respectlytics_flutter: ^3.0.0

Pure Dart — no platform channels for analytics. Same code on every platform Flutter compiles to (iOS, Android, web, macOS, Windows, Linux). On web, events are sent via the REST API; mobile platforms use the same path.

Initialize Respectlytics in Flutter

dart Respectlytics
import 'package:flutter/material.dart';
import 'package:respectlytics_flutter/respectlytics_flutter.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Respectlytics.configure(appKey: '<YOUR_APP_KEY>');
  runApp(const MyApp());
}

Initialize in main() after WidgetsFlutterBinding.ensureInitialized() and before runApp(). The future completes immediately on configuration; events queued before completion are flushed once the network is available.

Track the event in Flutter

dart Respectlytics
import 'package:respectlytics_flutter/respectlytics_flutter.dart';

Future<void> redeemReferral(String code) async {
  final response = await referralApi.redeem(code);
  Respectlytics.track(response.ok ? 'referral_redeem' : 'referral_redeem_failed');
}

Same discipline as other frameworks: code stays in api, analytics gets the outcome event_name.

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.

The Flutter SDK is pure Dart. No MethodChannel, no platform-specific iOS or Android plugin code. The same code runs on every platform Flutter supports — including web and desktop targets. This eliminates one common audit surface ("what's the Android implementation doing?").

Always initialize after WidgetsFlutterBinding.ensureInitialized() and before runApp(). If you skip the binding step, the configure call will throw on platforms that need a binding for asynchronous I/O. The SDK documentation example uses this pattern by default.

How this compares to other analytics SDKs

Referral redemption eventFirebase AnalyticsMixpanelRespectlytics
Referral code storedCommonCommonRejected by API
Referrer user ID storedYesYesNever
Referree user ID storedYesYesNever
Reward amount storedRecommendedRecommendedOut of scope
Redemption *rate* by country / platformYesYesYes

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.

Related guides

Track what matters. Collect nothing you don't.

Five-field event schema, RAM-only event queue, no IDFA, no AAID, no persistent user IDs. Helps developers avoid collecting personal data in the first place.