Rovenue SDKBeta
FunnelsWeb

Claiming the Result

How what a visitor did on a web funnel reaches your app — the claim token, the four ways an install finds it, and exactly which fields you get back.

A web funnel runs in a browser and your app runs on a device. Claiming is how the two are joined: the browser ends up holding a one-time token, the app redeems it, and the answers and the purchase become that subscriber's.

The token

When a visitor pays through a web funnel's checkout, the server mints a claim token: 32 random bytes (apps/api/src/services/funnel/token.ts:9-12), stored only as a hash. The plaintext is never stored: it leaves the server only in the response that minted it (apps/api/src/services/funnel/claim-email.ts:11-16), and the paths that replace it — a deferred match, its re-issue to the same install, a magic-link request — rotate the hash and hand the new plaintext to that one caller (apps/api/src/routes/v1/funnel-claim.ts:168-187, apps/api/src/routes/v1/funnel-claim.ts:978-1028, apps/api/src/routes/v1/funnel-claim.ts:1069-1094). It is valid for 7 days (apps/api/src/services/funnel/complete-purchase.ts:39) and redeemable once: redeeming it again from the same subscriber returns the same payload without running the merge twice (apps/api/src/routes/v1/funnel-claim.ts:787-793); from a different subscriber it fails with 409 Token already claimed (apps/api/src/routes/v1/funnel-claim.ts:794, apps/api/src/routes/v1/funnel-claim.ts:859). Two more 409s carry a typed error.code. PURCHASE_ALREADY_BELONGS: the purchase already sits on an app account (the customer holding it is identified, or was merged into one), so it is never poured into another device; the token stays claimable by that account, and nothing was moved (apps/api/src/routes/v1/funnel-claim.ts:456, apps/api/src/routes/v1/funnel-claim.ts:485). A restore through the email link answers it too once the purchase has already moved (apps/api/src/services/funnel/purchase-restore.ts:339). RESTORE_TARGET_RETIRED: during an email restore, the restoring customer was merged into another one or erased after the restore started. Nothing was written, and it is retryable: retry the claim, and it restores onto the customer the install now resolves to. The server keeps the restore secret for that retry, and the SDKs retry it on their own before they report it (see claimFunnelToken) (apps/api/src/services/funnel/purchase-restore.ts:271-288). A plaintext a rotation has replaced is no longer a token at all: it answers 404 Unknown token, not 409 (apps/api/src/routes/v1/funnel-claim.ts:715-723). An expired token answers 410 (apps/api/src/routes/v1/funnel-claim.ts:770-772). While Redis is unavailable, an unknown token can answer the typed 503 instead of 404: a value no claim token hashes to is first checked against the restore secrets kept in Redis (apps/api/src/routes/v1/funnel-claim.ts:672-673, apps/api/src/routes/v1/funnel-claim.ts:722).

Getting it to the app

If the app was not installed yet, there is nothing to open. After a fresh install the SDK can ask whether a recent visit belongs to this device. You call claimInstall() with no arguments on Swift and Kotlin: the façade collects the device context itself, so there is no referrer or locale for you to plumb through (packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1144, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1117).

  • Android reads the Play install referrer, which the universal-link landing wrote (apps/api/src/routes/public/funnel-universal.ts:7-9). The Kotlin façade reads it for you (packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/attribution/DeviceContext.kt:21-35). The referrer is authoritative: a token in it is looked up and handed straight back (apps/api/src/routes/v1/funnel-claim.ts:896-916). It only exists if the buyer reached the Play Store through the universal link — a buyer who searches the store by name has no referrer, and there is no fallback match for them (apps/api/src/routes/v1/funnel-claim.ts:1031-1032).

  • iOS starts from the unclaimed visits on the same hashed IP in the last hour, keeps only those whose device agrees with the launching device, and grants only when exactly one survives — never a guess between two (apps/api/src/routes/v1/funnel-claim.ts:918-976, apps/api/src/services/funnel/deferred-match.ts:34-52). A visit agrees when every one of these that both sides know matches (apps/api/src/services/funnel/fingerprint.ts:189-203):

    • screen pixels, compared portrait;
    • timezone;
    • device class — the model identifier's iPhone / iPad prefix against the class the landing recorded;
    • language, on its primary subtag (en matches en-US, de does not match en), against the visit's Accept-Language (apps/api/src/services/funnel/fingerprint.ts:165-169).

    A value either side does not know is skipped, not failed. The Swift façade fills the language, timezone, screen and model (packages/sdk-swift/Sources/Rovenue/Internal/ClaimDeviceContext.swift:20-31). Once a visit has matched, its screen, timezone and device class are cleared; only what a re-issue needs stays.

The window is one hour from the visit (apps/api/src/routes/public/funnel-universal.ts:67). What follows from the rule:

  • Two buyers behind one IP — a household, an office, a carrier's CGNAT — each match their own purchase when their devices differ (an iPhone and an iPad, two screen sizes, two timezones). A non-buyer on the same Wi-Fi with a different device gets nothing.
  • The residual risk is a same-model device, on the same network, in the same timezone and language, launching first inside the hour: it is indistinguishable from the buyer and takes the purchase. The buyer recovers it by email (below).
  • No JavaScript. Without a script the page falls back to a meta refresh (and a visible link) that records the visit with every device value unknown, so that visit matches on IP and language alone (apps/api/src/routes/public/funnel-universal.ts:83, apps/api/src/routes/public/funnel-universal.ts:227-236).
  • iCloud Private Relay gives Safari a different IP from the app, so those buyers never match by IP; the clipboard and email paths are their route.
  • An IP change between the visit and the first launch (Wi-Fi to cellular) means no match, and anything older than an hour is gone.

A declined match is the normal outcome, not an error — claimInstall() returns nil / null, and the clipboard and email paths are the fallbacks.

An install gets one deferred match per project. Once it has matched a visit — claimed or not, on any network — it never takes another, so a second launch cannot pick up a different buyer's visit on the same IP (apps/api/src/routes/v1/funnel-claim.ts:938-955).

Retrying claimInstall() after a lost response is safe. A repeat from the install that matched, while the visit's hour is open and the token is unclaimed, gets a fresh token for its own match — even from a different network, since a Wi-Fi to cellular switch is the usual way a response gets lost. The device language must still agree. Of two overlapping repeats exactly one gets the token and the other gets nil / null; ask again and it is re-issued (apps/api/src/routes/v1/funnel-claim.ts:168-187, apps/api/src/routes/v1/funnel-claim.ts:1007-1027). Every re-issue rotates the hash, so a plaintext handed out earlier — including a magic link already emailed — stops working; the email path can simply be asked again.

Run claimInstall() once per install. React Native's resolveFunnelClaim already does, through hasResolvedFunnelClaim (packages/sdk-rn/src/api/funnel.ts:152). On Swift and Kotlin, gate the call on hasResolvedFunnelClaim(), which reads persisted install state and turns true once a claim succeeds (packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1126, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1091), as the examples under Redeeming it do.

The success screen's CTA also writes a rovenue-funnel:<token> clipboard marker for iOS installs (apps/dashboard/src/runner/clipboard.ts:9-10, apps/dashboard/src/runner/funnel-runner.tsx:1749, apps/dashboard/src/runner/funnel-runner.tsx:1753). Read it with claimFromClipboard() from a user gesture — iOS asks the user before an app reads the pasteboard.

For a buyer who closed the tab. Two ways in:

Rovenue emails them. When the Stripe webhook completes the purchase first — a closed tab, a phone that slept — the token is minted with nobody there to receive it, and the buyer is emailed the same link the success screen would have shown (apps/api/src/services/funnel/claim-email.ts:11-21, apps/api/src/services/stripe/stripe-webhook.ts:598-617). This needs the funnel to have a deep link or a universal link configured; without one there is nowhere to send them, and no email goes out (apps/api/src/services/funnel/claim-email.ts:48-54).

The app asks. Your app can also ask Rovenue to look up an email; if there is a match, Rovenue emails a magic link that opens the app. That call always answers 202 with a null body whether or not a match existed, so it cannot be used to test which addresses have bought. No branch waits on the mail provider; branches still differ by a few indexed reads, and the call is rate-limited (apps/api/src/routes/v1/funnel-claim.ts:1036-1045, apps/api/src/routes/v1/funnel-claim.ts:1049-1131). What that mail is depends on the purchase behind the email:

  • A live unclaimed token for the email takes precedence: Rovenue rotates it and mails the magic link that redeems it (apps/api/src/routes/v1/funnel-claim.ts:1069-1094).
  • Already claimed by an anonymous install — the buyer's own app on a phone they no longer have, or another device that matched first — Rovenue mails a restore link. The device that opens the restore link gets the purchase: it moves to that device's subscriber (apps/api/src/routes/v1/funnel-claim.ts:1096-1124, apps/api/src/routes/public/funnel-magic.ts:97-118, apps/api/src/routes/v1/funnel-claim.ts:719-759, apps/api/src/services/funnel/purchase-restore.ts:317).
  • Already on an app account (a subscriber with your app user id) gets a "sign in with your account" mail instead; nothing moves and no link is sent (apps/api/src/services/funnel/purchase-restore.ts:244, apps/api/src/routes/v1/funnel-claim.ts:1125-1128).
  • Refunded or lapsed purchases are not restored, and nothing is mailed when the asking device already owns the purchase (apps/api/src/services/funnel/purchase-restore.ts:186-210, apps/api/src/services/funnel/purchase-restore.ts:241-242). A restore link opened after a refund answers 410 (apps/api/src/services/funnel/purchase-restore.ts:387).

This only works for funnels that took payment on the page — the payment-intent request requires the email, and only its keyed hash is ever stored, never the plaintext (apps/api/src/routes/public/funnel-payment.ts:76-79, apps/api/src/routes/public/funnel-payment.ts:1161-1177).

Redeeming it

let token = "<token from the opened URL>"
let result = try await Rovenue.shared.claimFunnelToken(token)
print(result.subscriberId)
print(result.funnelAnswersJson)
print(result.funnelPreselectedJson) // e.g. ["goal"]

// A fresh install with no token in hand: the façade reads the device
// context itself, and returns nil when nothing matches. Ask once per install.
var deferred: FunnelClaimResult? = nil
if !Rovenue.shared.hasResolvedFunnelClaim() {
    deferred = try await Rovenue.shared.claimInstall()
}

// From a user gesture: read the web funnel's pasteboard marker.
let fromClipboard = try await Rovenue.shared.claimFromClipboard()

claimFunnelToken is at packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1132, claimInstall() at :1129 and claimFromClipboard() at :1148. Observe claims resolved by any path on Rovenue.shared.funnelClaims (packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1109).

val token = "<token from the opened URL>"
val result = Rovenue.shared.claimFunnelToken(token)
println(result.subscriberId)

// A fresh install with no token in hand: the façade reads the Play install
// referrer and the device context itself, and returns null on no match.
// Ask once per install.
val deferred = if (Rovenue.shared.hasResolvedFunnelClaim()) null else Rovenue.shared.claimInstall()

// Android has no clipboard handoff; this is always null, so shared code
// needs no platform check.
val fromClipboard = Rovenue.shared.claimFromClipboard()

Rovenue.shared is the configured instance (packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:452-454); claimFunnelToken is at Rovenue.kt:1082, claimInstall() at :1099 and claimFromClipboard() at :1124. funnelClaims streams claims resolved by any path (packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1177).

import { Rovenue } from "@rovenue/react-native-sdk";

const openedUrl = "<the URL that opened the app>";
const token = "<token from the opened URL>";

// One call that tries the lot: the opened URL, then the deferred match.
const claim = await Rovenue.resolveFunnelClaim({ url: openedUrl });

// Or redeem a token you already have:
const result = await Rovenue.claimFunnelToken(token);

resolveFunnelClaim runs the no-gesture chain — the deep link, then the platform deferred match — while the clipboard and the email link stay gesture fallbacks you surface yourself (packages/sdk-rn/src/api/funnel.ts:141-157).

const token = '<token from the opened URL>';
const openedUrl = '<the URL that opened the app>';

final result = await Rovenue.instance.claimFunnelToken(token);

// Or let the SDK read the token out of the URL that opened the app:
final claim = await Rovenue.instance.claimFromUrl(openedUrl);

(packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:29, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:297, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:335-338).

What you get back

The claim payload carries four fields (buildClaimResponse in apps/api/src/routes/v1/funnel-claim.ts):

FieldWhat it is
subscriber_idThe subscriber this device now is
entitlementsThe live entitlement identifiers after the merge
funnel_answersOne flat map of question id to the recorded value
funnel_preselectedThe question keys an app value preselected (defaultFrom) that the visitor left unchanged — so a default can be told from a choice

funnel_answers is built from the session's stored answers (apps/api/src/routes/v1/funnel-claim.ts:529-537). entitlements is the live access set — active and unexpired, translated to catalog identifiers by the same rule the entitlements endpoint uses (apps/api/src/routes/v1/funnel-claim.ts:539-560) — and it is read after the claim transaction commits, because only then can it see the merge (apps/api/src/routes/v1/funnel-claim.ts:513-520). funnel_preselected is the machine's own record from the session state: answering a preselected question removes its key.

The SDK result types surface the subscriber, the answers and the preselected keys (FunnelClaimResult in packages/core-rs/src/funnel/mod.rs, which the Swift, Kotlin and Flutter types are generated from; packages/sdk-rn/src/api/funnel.ts):

SDKAnswersPreselected keys
Swift / KotlinfunnelAnswersJson (JSON object string)funnelPreselectedJson (JSON array string)
React NativefunnelAnswers (parsed object)funnelPreselected (parsed string[])
FlutterfunnelAnswersJsonfunnelPreselectedJson

funnelPreselectedJson is "[]" (React Native: []) when nothing was preselected or when the server predates the field — never an error.

What happens to the subscriber

A buyer who paid on the web has no install yet, so the purchase is held on an unclaimed buyer: an anonymous subscriber with a server-minted srv_… id and no app user id, found again by its Stripe customer (stripe:<customer id>, recorded as one of the buyer's ids) (apps/api/src/services/funnel/complete-purchase.ts:325-364). Claiming merges it into the device's subscriber — purchases, revenue, entitlements and credit balances move across, and the buyer is retired — inside the same transaction that spends the token, so it cannot happen twice (apps/api/src/routes/v1/funnel-claim.ts:805-823). The claim also flips the session to completed and emits funnel.session.completed with funnel.claim_token.claimed (apps/api/src/routes/v1/funnel-claim.ts:825-851).

The claim is a recorded merge, like every other one (apps/api/src/routes/v1/funnel-claim.ts:853):

  • an entry in the project's audit log;
  • a subscriber.merged webhook with reason FUNNEL_CLAIM, from the buyer to the device's subscriber;
  • an entry in the customer's Activity in the dashboard, for example "Web purchase from date linked — customer id merged into this one (claim link)", naming how the install found the token: claim link, deferred or email (see Customers in the dashboard).

The buyer's ids keep working after the claim: the server-to-server API resolves its srv_… id and its stripe: identifier to the survivor, and later Stripe events for the same customer land there too.

claimFunnelToken, claimInstall, claimFromClipboard and claimViaEmail are members of the SDK object on Swift, Kotlin, React Native and Flutter (packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1132, packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1144, packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1163, packages/sdk-swift/Sources/Rovenue/Rovenue.swift:1173, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1100, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1117, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1142, packages/sdk-kotlin/src/main/kotlin/dev/rovenue/sdk/Rovenue.kt:1151, packages/sdk-rn/src/index.ts:114-117, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:322, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:328-329, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:334, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:342). On all four, claimInstall() reads the device context itself and claimFromClipboard() exists; on Android (Kotlin, and React Native and Flutter running on Android) claimFromClipboard() always returns null. The helpers that read a token out of a URL — claimFromUrl and a bare extractFunnelToken — exist on React Native and Flutter only (packages/sdk-rn/src/api/funnel.ts:93, packages/sdk-rn/src/api/funnel.ts:135, packages/sdk-rn/src/index.ts:145, packages/sdk-flutter/rovenue_flutter/lib/src/rovenue.dart:360); on Swift and Kotlin you parse the opened URL yourself and call claimFunnelToken. resolveFunnelClaim, which tries every no-gesture path in turn, is React Native only (packages/sdk-rn/src/api/funnel.ts:150-172). The web SDK's surface is client, storage, cache, events and configure — it has no claim entrypoint (packages/sdk-web/src/index.ts:7-11, packages/sdk-web/src/index.ts:230).

On this page