Flutter Affiliate Tracking RevenueCat: The Dart Layer
Flutter affiliate tracking with RevenueCat is two Dart calls plus one string. The calls are MyAppAffiliate.start at launch and MyAppAffiliate.identify once you know the user. The string is whatever you pass to Purchases.logIn, because RevenueCat reports that back on every webhook as app_user_id and nothing else on the payload can join a purchase to a creator.
That is the easy half. A Flutter app is one codebase and two attribution environments, and a team that writes one path for both stores has a program that works for some of their users. Below: the Dart, the seam, and a gap in our own package worth knowing before you quote a rate. Every vendor fact here was opened on 2026-11-10.
#What a Flutter affiliate setup actually consists of
Four parts: a link or code a creator can share, something in the app that captures it, an identity call that binds it to your user id, and a webhook from whoever bills the subscription. Only the first two differ by store. Parts three and four are one Dart call and one server endpoint.
Pick your row: the Dart column is the same answer twice.
| Stage | Shared Dart | Under it on iOS | Under it on Android |
|---|---|---|---|
| Launch | `MyAppAffiliate.start(apiKey:)` | Nothing platform specific | Nothing platform specific |
| Link capture | `MyAppAffiliate.attribute(uri)` | Universal Links, needs Associated Domains | App Links, needs `assetlinks.json` |
| Code capture | `MyAppAffiliate.applyCode(code)` | Works on the first build | Works on the first build |
| Install with no link | Handled inside `start` | Probabilistic hashed IP match only | Probabilistic hashed IP match only |
| Identity | `MyAppAffiliate.identify(userId)` | Same string on both | Same string on both |
| Revenue | No Dart at all | RevenueCat webhook | RevenueCat webhook |
Two rows repay a second look. Link capture is the only one needing work in your native folders, and "install with no link" is where Flutter teams expect a difference our package does not give them. The store mechanics behind it belong to the iOS program setup and the Android program setup, neither of which changes because your app is Dart.
Our opinion on the order of work: ship the code path first. It needs no entitlement, no domain file and no review cycle to test, and in the setups we have seen it carries more first month installs than tracked links do.
#Where the creator id comes from on iOS and on Android
On iOS, from a Universal Link while the app is installed, from a typed code otherwise, or from a probabilistic match the server may decline. On Android, from an App Link, a typed code, or the same probabilistic match. The Play Install Referrer is the fourth Android option, and our Flutter package does not read it.
Here is the evidence. Our Android SDK documents MyAppAffiliate.applyInstallReferrer(referrer) as a Kotlin call you make after reading the referrer string with Google's com.android.installreferrer library. The Flutter SDK reference lists six calls and that is not one of them. Our integration matrix encodes the same split: the Flutter row expects claim_token, code and deferred_ip; the native Android row adds play_referrer.
It costs precision on one path: a Play Store install that followed a tracked link. The referrer survives the store visit deterministically, which is the argument of how install referrer attribution works. Without it a Flutter install on Android falls back to the hashed IP match, a guess the server is allowed to refuse.
Plan on both stores behaving like iOS: links when the app is already installed, codes when it is not, a probabilistic fallback behind both. That is worse than a native Kotlin build and better than most Flutter teams assume, because the code path alone pays creators correctly.
#Wiring identify() to the string RevenueCat reports back
One string, set in two places, and they have to be byte identical. Pass it to Purchases.logIn so RevenueCat stamps it on every webhook, and pass the same value to MyAppAffiliate.identify so the click already on file gets bound to it. There is no third place and no attribute to set.
Start the attribution SDK first, in main, before the first frame. This is copied from our Flutter SDK docs:
import 'package:myappaffiliate_flutter/myappaffiliate_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await MyAppAffiliate.start(apiKey: 'pk_live_…');
runApp(const MyApp());
}start generates and persists a device id, retries anything a previous launch failed to deliver, and asks the API for a deferred match on a fresh install. It returns false when no key was found, the one misconfiguration worth checking in a release build.
RevenueCat's own Dart goes next. Their configuring the SDK page sets the log level and configures, and their identifying customers page logs in afterwards, both read on 2026-11-10:
await Purchases.setLogLevel(LogLevel.debug);
await Purchases.configure(PurchasesConfiguration(<public_sdk_key>));
// Later log in provided user Id
LogInResult result = await Purchases.logIn(<my_app_user_id>);Then the same id, once, on our side:
await MyAppAffiliate.identify(userId);Expect nothing visible to happen. identify posts the pairing and resolves to a bool; on failure it resolves false rather than throwing, because an attribution SDK that can break a paywall gets deleted.
Three field definitions from RevenueCat's webhook event types and fields reference decide whether the join holds, checked on 2026-11-10. app_user_id is the "Last seen App User ID of the subscriber". original_app_user_id is "The first App User ID used by the subscriber". aliases holds "All App User IDs ever used by the subscriber", and the page says to "search both the original_app_user_id and the aliases array".
That matters more in Flutter than in Swift. RevenueCat's Flutter configuration sample passes only an API key, no appUserID, so the app is anonymous between configure and logIn. Their identifying customers page says the SDK will "generate a new random App User ID (prefixed with $RCAnonymousID:)" in that state. A purchase completed in that window arrives on an id your attribution layer has never seen.
Our position: that is an ordering bug, not a design problem. Call Purchases.logIn and MyAppAffiliate.identify in the same function, before any paywall is reachable. We do not self-heal the other case, because our ingest does not consume TRANSFER or the aliases array, so an anonymous purchase followed by a login stays unattributed. Skip the subscriber attribute route too, for the ordering traps it adds.
#What purchases_flutter gives you, and what it never will
It gives you identity and money: an app_user_id you control and a webhook for every purchase, renewal and refund against it. It gives no affiliate concept, no click, no commission, no payout. Treat it as half an attribution system.
Version drift is worth a glance before you file a bug. pub.dev lists purchases_flutter at 11.0.1 on 2026-11-10, while RevenueCat's own Flutter installation page still shows purchases_flutter: ^10.10.0 the same day. A snippet copied from the docs page will not be the current major.
Which of those events move a creator balance is a separate question: four create commission, refunds arrive as CANCELLATION rather than as any event named refund, and the full event mapping covers all of them. Nothing in it changes for Flutter, because your app is not involved.
#How a link reaches a Flutter app, and what a cold start costs
Through a plugin, because Flutter has no built-in link stream. app_links is the one we point people at, and the whole wiring is one listen call into attribute. The failure everyone hits is a cold start, and it is a lifecycle mistake rather than a plugin bug.
Our docs show the forwarding in two lines:
final appLinks = AppLinks();
appLinks.uriLinkStream.listen(MyAppAffiliate.attribute);Each Uri is parsed for a claim token or a referral code and posted. A link with neither resolves false, so a normal in-app link costs nothing.
Now the cold start. The app_links README says uriLinkStream covers the "initial link and further" events, and in the same breath says to instantiate AppLinks early "to catch the very first link when the app is in cold state", read on 2026-11-10. Together those are the trap: the launch link is delivered once, and if AppLinks() is constructed inside a widget's initState three frames later, nothing was listening. Construct it in main() beside start, or read it directly: the AppLinks class reference lists getInitialLink() and getInitialLinkString() beside getLatestLink(), with app_links at 7.2.2 on 2026-11-10.
A second, quieter conflict produces the same symptom. Flutter ships its own deep link handling, and its deep linking documentation tells plugin users to turn it off: "you should opt out the Flutter's default deep link handler", by setting FlutterDeepLinkingEnabled to false in Info.plist or flutter_deeplinking_enabled to false in AndroidManifest.xml. Verified on 2026-11-10. Leave both on and the router may consume a launch URL as a route before your plugin sees it, on one platform and not the other, which is how a Flutter bug ends up looking like an iOS bug.
None of this is required. Codes need no plugin, no entitlement and no manifest edit.
#The install that arrived with no link at all
Most of them, on both stores. The App Store and Play both drop your claim token across the install, so start asks the API for a deferred match: an unattributed click from the same hashed IP inside a short window, 60 minutes by default. It is probabilistic, and when two creators are equally plausible the server declines rather than picks.
Three behaviours in our Flutter package change what you see in testing.
The ask happens once per install, not once per launch. A definitive answer sets maa.deferredTried and the question is never asked again. A network error or a 5xx is not an answer, so those retry on later launches up to a cap of three attempts, which exists because the server can only match inside that 60 minute window and a device still failing on launch four has nothing left to match.
A refusal is final. The API answers 404 when there is no attributable click and 409 when the match was ambiguous, and the SDK treats both as answers: it clears the pending payload instead of retrying. A 409 is the server choosing to pay nobody, which beats paying the wrong creator, and it is labelled probabilistic everywhere it surfaces. The window arithmetic is in how attribution windows work.
Reinstalls behave differently in Flutter than in native iOS, and our docs do not say so. Our Swift SDK persists its device id in the Keychain, which survives reinstalls. The Flutter package uses shared_preferences, NSUserDefaults on iOS and SharedPreferences or DataStore on Android, checked on 2026-11-10. Neither survives an uninstall. A Flutter reinstall therefore looks like a new install and re-enters the deferred path. That is the conservative behaviour for commission, and not the iOS property your native colleagues have.
The recovery path for everything above is the code field, which works whether the install was attributed or not:
await MyAppAffiliate.applyCode('LUMI');It resolves true when the code was accepted. A user who typed a code two days after installing is attributed from that point, which is why we do not treat an unattributed install as a lost one.
#One Flutter subscriber, six months, one refund
One subscriber on a $9.99 monthly plan at a 20 percent creator rate, installed from the App Store with no surviving link, declined by the deferred match, recovered by a typed code the next day. Three commissions, one reversal inside the hold, $4.00 owed. Each line is 999 × 2000 / 10000, or 199.8 cents, rounded to $2.00.
| Date | What happened in the Flutter app | RevenueCat event | Commission | Pending | Matured | Balance |
|---|---|---|---|---|---|---|
| 1 Mar | Fresh install, no claim token, `start` asks for a deferred match | None | None | $0.00 | $0.00 | $0.00 |
| 1 Mar | API answers 409, two creators equally plausible | None | None | $0.00 | $0.00 | $0.00 |
| 2 Mar | `applyCode('LUMI')` accepted | None | None | $0.00 | $0.00 | $0.00 |
| 2 Mar | `Purchases.logIn` then `identify` with the same id | None | None | $0.00 | $0.00 | $0.00 |
| 2 Mar | Subscription purchased | `INITIAL_PURCHASE` | +$2.00 | $2.00 | $0.00 | $2.00 |
| 16 Mar | Hold expires, no webhook | None | Status only | $0.00 | $2.00 | $2.00 |
| 2 Apr | First renewal | `RENEWAL` | +$2.00 | $2.00 | $2.00 | $4.00 |
| 16 Apr | Hold expires, no webhook | None | Status only | $0.00 | $4.00 | $4.00 |
| 2 May | Second renewal | `RENEWAL` | +$2.00 | $2.00 | $4.00 | $6.00 |
| 9 May | Refund requested and granted | `CANCELLATION` | -$2.00 | $0.00 | $4.00 | $4.00 |
| 2 Jun | Access ends | `EXPIRATION` | None | $0.00 | $4.00 | $4.00 |
Two rows carry the whole design. The 409 on 1 March is a program working correctly, not a bug to escalate. The refund on 9 May lands seven days after the commission it reverses, inside the 14 day hold, so the reversal is a status change rather than money clawed back from a creator already paid.
#Verify both stores before you promise a creator money
Run the whole loop twice, once per store, on a real device. A simulator install never has the context a store install has, and a team that tested only on the platform they develop on is the most common way a Flutter program ships half working.
- Build with the key supplied at compile time:
flutter build ios --dart-define=MYAPPAFFILIATE_API_KEY=pk_live_…, then the Android equivalent.MyAppAffiliate.start()then takes no arguments. - Turn logging on for the run with
await MyAppAffiliate.start(apiKey: 'pk_live_…', debug: true);and watch for theattributed toline. - Apply a code, then read it back with
final affiliateId = await MyAppAffiliate.attributedAffiliateId();and assert it is not null. Fastest proof the capture half works, with no store setup. - Call
Purchases.logInandMyAppAffiliate.identifywith the same literal string, then confirm the dashboard shows that user id against the click, not a$RCAnonymousID:value. - Make a sandbox purchase and confirm the webhook arrived and matched. Gate payouts on the environment field so sandbox never reaches a balance.
- Call
await MyAppAffiliate.reset();, relaunch, and confirm the install re-enters the deferred path. This is also the data erasure path, so test it before someone asks. - Repeat steps 2 to 6 on the other store. Compare the two results before you write a rate into a creator agreement.
Step 7 gets skipped, and it is the only one that catches the link capture asymmetry above.
#Where MyAppAffiliate fits on a Flutter team
MyAppAffiliate is an affiliate and creator attribution platform for subscription mobile apps and SaaS. It tracks affiliate links and codes from click to install, subscription, renewal and refund through RevenueCat, Adapty, Superwall, Stripe and Paddle webhooks, calculates commissions, and pays creators, with flat pricing and no percentage of revenue.
For Flutter: one pubspec line, two calls, shared_preferences as the only transitive dependency, no advertising id, no fingerprinting. What we lack is the Play Install Referrer path on the Dart side, named above rather than buried, and TRANSFER consumption for anonymous purchases that log in afterwards. Pricing is flat per month, because a revenue percentage gets expensive exactly when a program works. If your signup also happens on the web, one engine covering mobile and web is the same appId, not a second integration.
Does RevenueCat support Flutter affiliate tracking out of the box?
No. `purchases_flutter` identifies customers and reports purchases. It has no affiliate, creator or commission concept. What it gives an affiliate system is the `app_user_id` you set with `Purchases.logIn`, which RevenueCat stamps onto every webhook it sends you.
Which id should I pass to MyAppAffiliate.identify in a Flutter app?
The exact string you pass to `Purchases.logIn`. Not the RevenueCat anonymous id, not a device id, not an email. RevenueCat's webhook reference defines `app_user_id` as the last seen App User ID of the subscriber, and that is the only field the join can use.
Do I need app_links for Flutter affiliate tracking to work?
No. Creator codes work with no deep link setup at all, which is why we tell Flutter teams to ship `applyCode` first. You need a link plugin only if you want a tracked link to open the installed app directly instead of landing in a browser.
Why does my Flutter deep link work on a warm start and not a cold one?
Almost always because `AppLinks()` is created after the first frame, inside a widget, so nothing is listening when the launch link is delivered. Create it in `main()` before `runApp`, or read `getInitialLink()` once at startup.
Does the Flutter SDK read the Play Install Referrer?
Not today. `applyInstallReferrer` is on our Kotlin SDK only, so a Flutter app on Android falls back to the same claim token, creator code and deferred match set as iOS. The referrer is the one deterministic Android advantage a Flutter build does not inherit.
#Add the code field first, then the link handler
Do this today: add myappaffiliate_flutter to pubspec.yaml, put start in main() above runApp, put identify beside your existing Purchases.logIn call, and ship a "Got a code?" text field that calls applyCode. That is a working creator program with no store configuration, no Associated Domains and no assetlinks.json.
The link handler and the deep link opt-out flags come next week, once a code has paid out once. If RevenueCat is new in your stack too, start from the full RevenueCat attribution setup and come back to the Dart.