Kerdly

Guides

App with web payments

An iOS or Android app that also sells through a web checkout (Stripe, Paddle, RevenueCat Web Billing). Set up RevenueCat or your server's webhooks and the SDK so every purchase, in the store or on the web, lands on the same user and the same ad.

View as Markdown

Use this guide when the same customer can pay in more than one place: in the app through the App Store or Google Play, and on the web through Stripe, Paddle or RevenueCat Web Billing (for example a paywall that opens a web checkout, or a website plan that unlocks the app).

Example: Tallybird's apps sell through the stores, and tallybird.example/upgrade sells the same Pro plan through Stripe for 20% less. A user can install from a TikTok ad, sign up in the app, and pay on the web.

Start with App with App Store and Google Play billing: everything there still applies. This guide adds the web money and the one thing that ties it all together: the same user id everywhere.

The rule: one user id, everywhere

WhereWhat to set it to
App SDKKerdly.setUserId(user.id)
Web SDK, on your checkout pageskerdly.identify(user.id)
RevenueCatappUserID = user.id (Purchases.logIn(user.id))
Stripe / Paddleuser.id in the customer's and subscription's metadata
Your server's eventsuser_id: user.id

Kerdly then finds the install for any web charge through the user: the install that last identified with that user id, and with it the install's day, campaign and ad.

What you get today

App Store / Google Play purchasesWeb purchases
Revenue in reportsThe iOS and Android apps' Dashboard, Cohorts and P&LThe project's Web app reports, credited to the visit and ad that brought the buyer to the site
Credited to the app install's ad in the app's cohortsYesNot yet; being built
Sent to Meta and TikTok as the app's conversionYesYes, when your server sends the charge with the app's server key

So today, web money is set up in two parts: the Web app counts it, and (optionally) the app tells the ad networks about it.

1. Count web money in the Web app

Add a Website to the project if it has none (the project page → its apps). Then send web purchases to the Web app in one of these ways, only one: Kerdly reads each store (stripe, paddle, rc_billing) from one source only.

Option A: with RevenueCat

RevenueCat already knows every purchase under your appUserID.

  1. Connect the webhook. In the Web app's Settings, under RevenueCat, press Generate next to Webhook authorization and copy the value. Then in RevenueCat → Project settings → Integrations → Webhooks → Add:
    • URL: https://app.kerdly.com/api/revenuecat?app=<the Web app's Kerdly id>
    • Authorization header: the value you copied. Save in Kerdly too; Kerdly keeps only a hash of the value.
  2. Backfill history (optional): add the RevenueCat project id and a V2 secret API key with read access to customer information. The first pass starts within the hour.
  3. Identify in RevenueCat with your user id: Purchases.logIn(user.id) in the app, and the same appUserID for web purchases.
  4. Web purchases started on your website: set the subscriber attribute kerdly_visitor_id to kerdly.visitorId(), so the purchase finds the visit even before the user signs in.

App Store and Google Play purchases in the same RevenueCat project are not counted in the Web app; the store apps read them from Apple and Google, so nothing is counted twice.

Option B: connect Paddle or Stripe

Kerdly reads every charge, renewal and refund straight from the provider, as in Sell on your website: a read-only API key in the Web app's Settings → Connections, and the user id (the same as setUserId) on every checkout under the Web app's User id field.

Option C: your own Stripe or Paddle webhooks

Your server reports each web charge to the Web app, with the Web app's server key, exactly as in Sell on your website. Send user_id (the same id as setUserId) on every event.

2. Optional: tell the ad networks about web purchases from app users

For users who installed from an app ad and then paid on the web, your server can also send the charge to the app with the app's server key (Tallybird iOS or Android, from that app's Settings → SDK). Kerdly finds the install through user_id (or install_id, if your backend has it from await Kerdly.getInstallId()) and, with postbacks on, sends the conversion to that install's network with its ad.

js
await sendKerdlyEvents([{
  event_id: `stripe:${invoice.id}`,
  name: paidBefore ? "renewal" : sub.trial_start ? "trial_conversion" : "subscribe",
  ts: invoice.status_transitions.paid_at * 1000,
  user_id: sub.metadata.user_id,
  props: {
    transaction_id: invoice.charge,
    subscription_id: sub.id,
    product_id: "tallybird_pro_annual_web",
    product_kind: "subscription",
    value: invoice.amount_paid / 100,
    net_value: netAfterFeesAndTax,
    currency: invoice.currency.toUpperCase(),
    store: "stripe",
  },
}], process.env.KERDLY_IOS_SERVER_KEY);

Use the same event_id you sent to the Web app. The app's revenue reports don't read these events, so the charge is not counted twice.

Never send App Store or Google Play charges from your server: they come from the stores.

Tie the account to the install from your backend

If users sign up through your backend (say, an email magic link) and you'd rather not wait for the app's setUserId, your server can link them itself with the app's server key:

sh
curl https://app.kerdly.com/api/v1/s2s/identify \
  -H "Authorization: Bearer $KERDLY_SERVER_KEY" -H "Content-Type: application/json" \
  -d '{ "identities": [{ "user_id": "user_8f2k1", "install_id": "3f2504e0-4f89-41d3-9a0c-0305e82c3301" }] }'

An identity names a user_id and an install_id (from Kerdly.getInstallId()) or a visitor_id (from kerdly.visitorId()). An install the app already identified keeps the app's user.

Opening the web checkout from the app

When the app's paywall sends the user to the web, pass the user along so the checkout knows them, for example https://tallybird.example/upgrade?uid=<user.id> behind your own sign-in. The web SDK on the checkout page records the visit; identify(user.id) ties it to the user. Don't add the visitor id to links that point back into the app.

Check it

  1. Install from a test link, sign up in the app, then buy on the web in test mode.
  2. Your server's request answers accepted; with RevenueCat, RevenueCat's webhook page shows Kerdly's endpoint answering 200.
  3. The Web app's Dashboard shows the charge; with step 2 and postbacks on, the app's postbacks show the purchase sent for the install.

Agent checklist

  • One user id in setUserId, identify, RevenueCat's appUserID, Stripe or Paddle metadata, and every server event.
  • Web money to the Web app, from RevenueCat or your server, not both.
  • Optional: the same charge, same event_id, to the store app with its server key, for postbacks.
  • No store charges from the server; notifyPurchase stays in the app.