Skip to main content
6 min read

How to Add Affiliate Tracking to Your Adapty App

Connect Adapty to Appfiliate for automatic affiliate attribution on subscription events. Track which creators drive paying subscribers with webhook integration.

A
Appfiliate
How to Add Affiliate Tracking to Your Adapty App

If you use Adapty to manage subscriptions, you can add affiliate tracking to your app in about five minutes. Appfiliate connects to Adapty via webhooks so every subscription event — purchases, renewals, trials, cancellations — is automatically attributed to the creator who drove the install. No manual trackPurchase() calls needed.

Here is the full setup.

Step 1: Integrate Appfiliate SDK

Add the Appfiliate SDK to your project and initialize it. Here are the steps for each platform:

iOS (Swift)

You should integrate the SDK into your App init() or AppDelegate didFinishLaunchingWithOptions:

import Appfiliate

// In your App init() or AppDelegate didFinishLaunchingWithOptions:
Appfiliate.configure(appId: "APP_ID", apiKey: "API_KEY")
Appfiliate.trackInstall()

Android (Kotlin)

Add JitPack to your settings.gradle.kts repositories and then add the dependency to your app's build.gradle.kts:

dependencies {
    implementation("com.github.Appfiliate-sdk:appfiliate-android-sdk:1.0.0")
}

Then, initialize the SDK in your Application or main Activity:

import com.appfiliate.sdk.Appfiliate

Appfiliate.configure(this, appId = "APP_ID", apiKey = "API_KEY")
Appfiliate.trackInstall(this)

Flutter (Dart)

Add to your pubspec.yaml:

dependencies:
  appfiliate: ^1.0.0

Then initialize in your main() or root widget's initState:

import 'package:appfiliate/appfiliate.dart';

Appfiliate.configure(appId: 'APP_ID', apiKey: 'API_KEY');
await Appfiliate.trackInstall();

React Native

npm install appfiliate-react-native

Then in your root component:

import { appfiliate } from 'appfiliate-react-native';

appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
await appfiliate.trackInstall();

Your appId and apiKey are available in your Appfiliate dashboard. If you don't have an account yet, sign up at appfiliate.io and check pricing to pick a plan.

trackInstall() is idempotent. It only sends data on the first launch, so calling it on every app start is safe.

Step 2: Link the Adapty user ID

This is the most important step. After calling trackInstall(), pass the Adapty profile ID to Appfiliate using setUserId(). This creates the link between the attributed install and the Adapty subscription profile so that webhook events can be matched.

iOS

Appfiliate.configure(appId: "APP_ID", apiKey: "API_KEY")
Appfiliate.trackInstall()
Appfiliate.setUserId(Adapty.profileId)

Android

Appfiliate.configure(this, appId = "APP_ID", apiKey = "API_KEY")
Appfiliate.trackInstall(this)
Appfiliate.setUserId(this, Adapty.profileId)

Flutter

Appfiliate.configure(appId: 'APP_ID', apiKey: 'API_KEY');
await Appfiliate.trackInstall();
await Appfiliate.setUserId(await Adapty.getProfileId());

React Native

appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
await appfiliate.trackInstall();
await appfiliate.setUserId(await adapty.getProfileId());

Make sure the user ID you pass matches the profile ID that Adapty includes in its webhook payloads. If they do not match, Appfiliate cannot connect the subscription event to the attributed install.

Step 3: Add the webhook URL in Adapty

Go to your Adapty dashboard, then navigate to Integrations and select Webhooks. Add the following URL as a new webhook endpoint:

https://us-central1-appfiliate-5a18b.cloudfunctions.net/api/v1/webhooks/adapty?secret=YOUR_WEBHOOK_SECRET

Replace YOUR_WEBHOOK_SECRET with the webhook secret from your Appfiliate dashboard. This secret authenticates the webhook so that only legitimate events from your Adapty account are processed.

That is the entire setup. No additional configuration, no event filtering, no custom payload mapping.

What events are tracked

Once the webhook is connected, Appfiliate processes all subscription lifecycle events that Adapty sends:
  • Initial purchase, a user subscribes for the first time. The revenue is attributed to the creator who drove the install.
  • Renewal, an existing subscription renews. Recurring revenue continues to be attributed to the original creator.
  • Trial started, a user begins a free trial. The creator gets credit for the trial conversion.
  • Trial converted, a trial converts to a paid subscription.
  • Cancellation, a user cancels. This updates the creator's metrics so you have an accurate picture of net revenue.
All of this happens automatically. You do not need to instrument individual events in your app code. Adapty handles the billing lifecycle, sends the events via webhook, and Appfiliate attributes them to the right creator.

Why use webhooks instead of trackPurchase()

The Appfiliate SDK includes a trackPurchase() method that you can call directly from your app code after a successful purchase. This works fine, but the webhook approach is better for Adapty users for a few reasons.

First, renewals happen server-side. When a subscription renews, your app might not be running. Webhooks capture these events regardless of app state. Second, Adapty already has all the purchase data including product IDs, revenue amounts, and currency. The webhook sends this data directly without you needing to extract it in your app code. Third, it is less code to maintain. One setUserId() call replaces every trackPurchase() call throughout your codebase.

If you are using Adapty, the webhook integration is the recommended approach. For a full list of supported subscription platforms, see our integrations page.

Frequently asked questions

Does the SDK require IDFA or an ATT prompt? No. The Appfiliate SDK does not use IDFA and does not require an App Tracking Transparency prompt. Attribution is handled through platform install referrer APIs and device context matching. What if the user is not attributed to a creator? If a user installs your app organically (not through a creator's tracking link), trackInstall() returns with no match. Webhook events for that user are received but not attributed to any creator. Only installs that came through a tracking link generate creator attribution. Can I use this alongside other Adapty integrations? Yes. Adapty supports multiple webhook endpoints. Adding the Appfiliate webhook does not interfere with any existing integrations you have configured, such as analytics, CRM, or other attribution tools. How quickly do events appear in the dashboard? Webhook events are processed in real time. When Adapty fires a subscription event, it appears in the Appfiliate dashboard within seconds. What does this cost? Appfiliate offers plans based on the number of tracked installs. Webhook events from Adapty do not count toward your install limit since they are tied to already-tracked installs. Check our pricing page for current plans.

Wrapping up

Adapty is excellent at managing subscriptions. Appfiliate is built to attribute those subscriptions back to the creators who drove them. Connecting the two takes one SDK call, one setUserId() line, and one webhook URL. Once connected, every subscription event in Adapty is automatically attributed to the right creator with no ongoing code maintenance required.

If you are running a creator program for your subscription app and already using Adapty, this integration gives you the missing piece: knowing exactly which creators are driving your paying subscribers and how much revenue each one generates.