Kerdly

Guides

App with App Store and Google Play billing

An iOS or Android app that sells subscriptions through StoreKit or Play Billing. Connect the stores, add the SDK, link every purchase to its install, and get LTV per install day, campaign and ad, with deferred deep links for Meta and TikTok.

View as Markdown

Use this guide when your app sells through the stores: Apple and Google charge the customer, renew the subscription and pay you out. This covers native apps, Expo and React Native, with or without a paywall SDK such as Superwall.

Example: Tallybird for iPhone and Android, built with Expo, sells tallybird_pro_weekly ($7.99, 3-day trial) and tallybird_pro_annual ($39.99, 7-day trial). It advertises on Meta, TikTok and Apple Ads with app-install campaigns.

How the numbers come together

Kerdly builds every report from three facts, and the steps below make sure each one exists:

  1. The install and its ad. The SDK records the install; Kerdly matches it to the click within 48 hours, then the answer is final.
  2. The money. Apple and Google report every trial, charge, renewal, refund and payout. This is the revenue Kerdly counts, so it matches your payouts.
  3. The link between them. notifyPurchase and the account token tie each store subscription to the install that bought it. Every later renewal or refund then lands on that install's install day, campaign, ad set and ad, which is what LTV, ROAS and payback per day and per ad are built from.
StepSent byHow
Install, opens, attribution signalsAppThe SDK, on its own
Sign-up, sign-inAppsetUserId, trackRegistration
Trial, first charge, one-time purchaseApp and storetrackStartTrial / trackSubscribe / trackPurchase in seconds; the store's own record follows and is the one counted
Link the purchase to the installAppsetAppAccountToken + notifyPurchase
Renewal, cancel, billing problem, expiry, refundStoreApp Store Server Notifications, Google Play real-time notifications, and daily reports
Conversions to Meta, TikTokKerdly's serverPostbacks, from the store's records

Your server sends nothing in this setup. If you also sell on the web, see App with web payments.

1. Create the apps and keys

An app that ships to both stores is two Kerdly apps, Tallybird iOS and Tallybird Android, in one project. Each app gets its app key (pk_live_…) when it is created: open its Settings → SDK to copy it. For test builds kept apart, add a pk_test_… key under Server keys and key rotation.

2. Connect the App Store (iOS)

Follow Connect App Store Connect. Do both parts:

  • Revenue and installs: the App Store Connect API key. Sales, payouts, installs and product names.
  • Real-time subscription events: the In-App Purchase key, and the project's notification URL https://hooks.kerdly.com/<project> pasted in App Store Connect under the app's App Information → App Store Server Notifications, Version 2, as the Production Server URL. Paste it as the Sandbox Server URL too if you want TestFlight and sandbox purchases.

Already sending notifications to RevenueCat, Superwall or your own server? Apple takes one URL per environment. Point it at Kerdly, then add each existing receiver under Project → Store notifications → Add a server; Kerdly forwards every notification to them unchanged.

3. Connect Google Play (Android)

Follow Connect Google Play for earnings, sales and installs. Then turn on real-time notifications.

Real-time developer notifications (RTDN)

Google doesn't call a URL: Play publishes each notification to a Pub/Sub topic. Kerdly creates and runs that topic for your project, so there is nothing to set up in Google Cloud.

  1. In the dashboard, open Project → Store notifications and copy the Google Play topic. It looks like projects/app-analytics-and-services/topics/rtdn-<project>. Kerdly has already allowed Google Play to publish to it (google-play-developer-notifications@system.gserviceaccount.com) and subscribed your project's notification address to it.
  2. In Play Console, open the app → Monetize with Play → Monetization setup.
  3. Under Real-time developer notifications, turn them on and paste the topic name. Choose to receive subscriptions, voided purchases and all one-time products.
  4. Press Send test notification, then Save changes.
  5. Back on Project → Store notifications, the Google Play card shows the test's time.

Play takes one topic per app. If the app's notifications already go to another topic (RevenueCat creates its own), you choose: point Play at Kerdly's topic for real-time events, or keep the other one and let Kerdly read Play's subscription data and reports, which arrive later but still in full.

4. Add the SDK

sh
npx expo install @kerdly/expo
json
{ "expo": { "plugins": [["@kerdly/expo", {
  "metaAppId": "1234567890123456",
  "userTrackingPermission": "Lets us measure which of our ads brought you to Tallybird."
}]] } }
ts
// app/_layout.tsx, at module scope
import { Platform } from 'react-native';
import { Kerdly } from '@kerdly/expo';

Kerdly.configure({
  key: Platform.select({
    ios: process.env.EXPO_PUBLIC_KERDLY_IOS_KEY!,
    android: process.env.EXPO_PUBLIC_KERDLY_ANDROID_KEY!,
  })!,
});

Native apps: the iOS SDK and Android SDK pages have the same calls in Swift and Kotlin. Full Expo reference: Expo SDK.

5. Identify users

ts
// after sign-up
Kerdly.setUserId(user.id);
Kerdly.trackRegistration({ method: 'apple' });

// after sign-in
Kerdly.setUserId(user.id);

// on sign-out
Kerdly.setUserId(null);

Apps without accounts can skip setUserId; the install id is enough. Use the same user id everywhere you have one: the app, your backend, RevenueCat.

This step is what puts renewals and refunds on the right install day and ad.

a. Give purchases an account token. Pick one stable UUID per user (or per install for apps without accounts), store it, and pass it to the store with each purchase:

  • iOS: StoreKit's appAccountToken (StoreKit 2 Product.PurchaseOption.appAccountToken(uuid); in react-native-iap / expo-iap, the appAccountToken purchase option).
  • Android: Play Billing's obfuscatedAccountId (setObfuscatedAccountId; in react-native-iap, obfuscatedAccountIdAndroid).

Tell Kerdly the same value as soon as you know it:

ts
Kerdly.setAppAccountToken(accountToken);

Using Superwall? Its alias already is the token: see With Superwall.

b. Report each completed purchase.

ts
function onPurchaseCompleted(tx: Purchase) {
  if (Platform.OS === 'ios') {
    Kerdly.notifyPurchase({
      originalTransactionId: tx.originalTransactionIdentifierIOS,
      transactionId: tx.transactionId,
      productId: tx.productId,
      appAccountToken: accountToken,
    });
  } else {
    Kerdly.notifyPurchase({ purchaseToken: tx.purchaseToken!, orderId: tx.transactionId, products: [tx.productId] });
  }
}

On iOS the SDK also sweeps the current entitlements on every launch, so a purchase made while the app was killed is still linked. After a restore, call Kerdly.notifyPurchase() with no argument.

c. Send the client events. They arrive in seconds, show in the dashboard right away and let postbacks reach the networks fast. The store's own record replaces them in revenue.

ts
Kerdly.trackStartTrial({ productId: 'tallybird_pro_annual', value: 0, currency: 'USD', transactionId });
Kerdly.trackSubscribe({ productId: 'tallybird_pro_weekly', value: 7.99, currency: 'USD', transactionId });

Don't send renewals, cancellations or refunds from the app: the stores report them.

7. iOS: tracking permission and SKAdNetwork

  • Ask for tracking where it makes sense in your onboarding: await Kerdly.requestTrackingAuthorization(). Users who allow it can be matched to their exact ad.
  • For users who don't, Apple's SKAdNetwork reports installs per campaign. In the iOS app's Settings → SKAdNetwork, copy the postback address into the plugin's skanEndpoint, so Kerdly receives a copy of every postback.

For app-install ads, the click happens inside Meta or TikTok and the user goes straight to the store, so there is no Kerdly click to match. A deferred deep link asks the network, from the device, which ad led to the install. The SDK makes that request itself; you don't need the Meta or TikTok SDK for it.

  1. Give every app ad a deep link that ends in the network's id macros. Your app should open it (any path works; tallybird://open here):
    • Meta: Ads Manager → the ad → Destination → Deep link: tallybird://open?utm_source=meta&campaign_id={{campaign.id}}&adset_id={{adset.id}}&ad_id={{ad.id}}
    • TikTok: the ad → Deeplink: tallybird://open?utm_source=tiktok&campaign_id=__CAMPAIGN_ID__&adgroup_id=__AID__&ad_id=__CID__
  2. TikTok turns deferred deep links on per app: ask your TikTok rep. Then enter the app's TikTok App ID (Events Manager → the app) in Kerdly.
  3. Meta (iOS): the SDK reads FacebookAppID and FacebookClientToken from the app. Without the Facebook SDK, enter the Meta app id and client token in Kerdly instead.
  4. In the app's Settings, under Deferred deep links, turn on Ask the networks for deferred deep links.

On iOS the networks are asked only for users who allowed tracking, unless you turn off Only users who allowed tracking. On Android, Meta isn't asked: Meta's Install Referrer and the Play referrer already name the ad (set metaAppId in the plugin, and the Meta install-referrer decryption key in Settings).

The link also opens the right screen on first launch: read the attribution and route.

ts
Kerdly.addAttributionListener((a) => {
  if (a.state === 'final' && a.campaign?.includes('streaks')) router.push('/streaks-intro');
});

9. Set up the ads

NetworkCampaign typeWhat to set
MetaApp promotionThe deep link from step 8. Spend comes from connecting Meta.
TikTokApp promotionThe deep link from step 8, plus deferred deep links on through your rep.
Apple AdsAnyNothing: the SDK reads Apple's attribution token on its own.
Google AdsApp campaignsNothing in the ad; Google's install referrer names the campaign on Android.

If an ad sends people to a website first, see Web-to-app funnel.

10. Send conversions back to the networks

In each app's Settings → Postbacks, add Meta (the app's dataset) and TikTok. Kerdly then sends each trial and first subscription from the store's records, server to server, with the install's device and attribution. The event id is <transaction id>:trial_start or <transaction id>:subscribe.

If the app already sends StartTrial or Subscribe through the Meta or TikTok SDK, either turn those calls off, or send them with that same event id and record each with Kerdly.recordNetworkSend, so the network counts each event once. See deduplication.

11. Check it

  1. Install a development build with logLevel: 'debug'; the console shows [Kerdly] lines.
  2. Buy a sandbox subscription. Within minutes the app's Onboarding page shows the SDK step with events today, and the App Store step shows real-time events.
  3. Each app's Onboarding page shows every step done.

Agent checklist

  • Two app keys, picked with Platform.select; configure at module scope.
  • setUserId on sign-up and sign-in, null on sign-out; trackRegistration on sign-up.
  • One account token per user, passed to StoreKit (appAccountToken) and Play (obfuscatedAccountId) and to Kerdly.setAppAccountToken.
  • notifyPurchase after every completed purchase; notifyPurchase() after a restore (iOS).
  • trackStartTrial / trackSubscribe / trackPurchase with productId, value, currency, transactionId.
  • No renewals, cancels or refunds from the app; no store charges from the server.
  • Network SDK conversions (if any) use <transaction id>:trial_start / :subscribe and recordNetworkSend.