> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flokitai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RevenueCat + AppsFlyer

> Connect the most common iOS subscription + attribution stack to FloKit.

**Goal:** Connect RevenueCat subscription data and AppsFlyer attribution to FloKit for accurate payback analysis.

This is the most common integration path for iOS-first subscription apps. Both platforms expose server-to-server APIs — no mobile SDK changes required.

***

## Before you start

* RevenueCat V1 API key available (Project Settings → API Keys → Secret keys).
* AppsFlyer V2.0 API token available (AppsFlyer → My Profile → API Token).
* RevenueCat `app_user_id` is explicitly set to your backend user ID — not an auto-generated RevenueCat anonymous ID.
* The same backend user ID is sent to AppsFlyer as `customer_user_id`.

***

## Steps

<Steps>
  <Step title="Connect RevenueCat">
    Go to **FloKit → Settings → Integrations → RevenueCat**.

    Enter your **Secret API key** (starts with `sk_`). FloKit uses this to pull subscription history via the RevenueCat REST API.

    **Enable the RevenueCat webhook (recommended):**
    In RevenueCat, go to **Project Settings → Webhooks → Add Webhook**.

    * URL: `https://api.flokit.ai/v1/integrations/revenuecat/webhook`
    * Events: select **Initial Purchase**, **Renewal**, **Cancellation**, **Expiration**, **Trial Started**, **Trial Converted**, **Refund**.

    The webhook reduces data latency from 6 hours to near real-time for subscription events.
  </Step>

  <Step title="Connect AppsFlyer">
    Go to **FloKit → Settings → Integrations → AppsFlyer**.

    Enter:

    * **API token** — your AppsFlyer V2.0 API token.
    * **App ID** — your App Store app ID (numeric, e.g. `1234567890`). Include the `id` prefix if prompted.

    FloKit pulls install and attribution data via the AppsFlyer Pull API. Attribution data includes campaign, ad set, creative, channel, country, and `customer_user_id`.
  </Step>

  <Step title="Verify identity join">
    Go to **FloKit → Data → Identity**.

    FloKit joins RevenueCat `app_user_id` to AppsFlyer `customer_user_id`. The join rate should be above 90%.

    **The most common integration issue with RevenueCat + AppsFlyer is a user ID mismatch.** RevenueCat generates a random `$RCAnonymousID` if you don't call `logIn()` or `configure()` with an explicit `appUserID`. AppsFlyer uses `customer_user_id`, which must be set via `setCustomerUserId()`. If these are not the same backend user ID, FloKit cannot match subscription events to attribution data.

    To diagnose:

    * In RevenueCat → Customer Lookup, find a test user and check their `app_user_id`. If it starts with `$RCAnonymousID`, explicit user ID is not being set.
    * In AppsFlyer → Raw Data Reports, check whether `customer_user_id` is populated for your installs.

    See [Identity mapping](/send-data/identity-mapping) for resolution steps.
  </Step>

  <Step title="Wait for historical backfill">
    FloKit begins a historical backfill immediately after both integrations are connected. Backfill covers the past 90 days by default and completes within 2–4 hours.

    Monitor progress at **FloKit → Data → Sources**.
  </Step>

  <Step title="Validate the payback report">
    Go to **Reports → Payback**. Set the date range to the past 30 days.

    Cross-check against your existing reporting:

    * **CAC**: compare to your internal CAC figure for the same period. Expected tolerance: ±5%.
    * **Trial conversion rate**: compare to RevenueCat → Charts → Trial Conversion. Expected tolerance: ±2%.
    * **Renewal rate**: compare to RevenueCat → Charts → Subscriber Retention. Expected tolerance: ±2%.

    If numbers diverge more than 10%, follow the [validate CAC payback](/recipes/validate-cac-payback) recipe before enabling recommendations.
  </Step>
</Steps>

***

## Validation checklist

* [ ] RevenueCat API key accepted, historical backfill complete
* [ ] AppsFlyer API token accepted, attribution data visible
* [ ] Identity join rate above 90%
* [ ] No `$RCAnonymousID` entries visible in FloKit → Data → Identity
* [ ] CAC within ±5% of your existing report
* [ ] Trial conversion within ±2% of RevenueCat dashboard

***

## Troubleshooting

**Join rate is low**
The most likely cause is anonymous RevenueCat user IDs. Check RevenueCat → Customer Lookup for `$RCAnonymousID` entries. Resolve by ensuring `logIn()` or `configure(appUserID:)` is called with your backend user ID immediately after authentication. See [Identity mapping](/send-data/identity-mapping).

**Attribution data is missing for some installs**
AppsFlyer `customer_user_id` may not be set at install time if the user hasn't authenticated yet. If your app authenticates users after install (typical), you may need a server-side identity resolution step. See [Identity mapping](/send-data/identity-mapping).

**RevenueCat webhook events not arriving**
Verify the webhook URL in RevenueCat matches exactly: `https://api.flokit.ai/v1/integrations/revenuecat/webhook`. Check **FloKit → Data → Sources → RevenueCat → Webhook log** for delivery status.
