
# Client events, server events and deduplication

Every guide in this section uses the same rules. This page collects them in one place.

## Who sends what

| Event | From the client (app SDK, web SDK) | From your server (`/v1/s2s/events`) | From the store or RevenueCat |
|---|---|---|---|
| Ad click, visit | Web SDK, on every page | Optional: `/v1/s2s/touchpoints`, when your own server redirects | |
| Click on a Kerdly link | | | Recorded by the link itself |
| Install, open, deep link | App SDK | | |
| Identify (user id) | `identify` / `setUserId` | `/v1/s2s/identify` | |
| Registration | `trackRegistration` | Custom event | |
| Trial start | `trackStartTrial` | `start_trial` (web sales) | App Store, Google Play, RevenueCat |
| First paid charge | `trackSubscribe` | `subscribe` or `trial_conversion` (web sales) | App Store, Google Play, RevenueCat |
| One-time purchase | `trackPurchase` | `purchase` (web sales) | App Store, Google Play, RevenueCat |
| Renewal | | `renewal` (web sales) | App Store, Google Play, RevenueCat |
| Cancel, billing problem, expiry | | | App Store, Google Play |
| Refund | | `refund` (web sales) | App Store, Google Play, RevenueCat |

## Where revenue comes from: one source per store

Revenue is never added up from several places. For each store an app is paid through, Kerdly reads
money from exactly one source:

| Store | Default source |
|---|---|
| The app's own store (`app_store` for an iOS app, `play_store` for an Android app) | The store itself: its notifications and reports |
| `paddle` and `stripe` on the project's **Web app**, with that provider connected | The provider itself: Kerdly reads its charges, renewals and refunds |
| Other web stores (`rc_billing`, `web`, and Paddle or Stripe not connected) on the **Web app** | RevenueCat, when the Web app has RevenueCat connected; otherwise your server's events |
| Web stores on an iOS or Android app | Not counted in that app's reports yet; count them in the Web app (see [App with web payments](https://kerdly.com/docs/guides/app-web-payments.md)) |

So:

- **In an app, don't send App Store or Google Play charges from your server.** They are read from
  the store; server copies of them don't count as revenue.
- **The SDK's `trackStartTrial` / `trackSubscribe` / `trackPurchase` are signals, not revenue.** They
  arrive in seconds, tell the ad networks early, and fill the gap until the store reports the
  charge. The revenue in reports is the store's.
- **Web charges come from one place.** A connected Paddle or Stripe is the source of its own
  charges, so don't send them from your server too. With RevenueCat connected to the Web app,
  RevenueCat is the source for the other web stores. To change it, set **Revenue sources** in
  the Web app's **Settings**, under **Revenue**: for example `stripe` read from your server.

## How Kerdly counts each thing once

| What | The key | What happens to a repeat |
|---|---|---|
| An SDK event | The event id the SDK gives it | Retries after a network error are stored once. |
| A server event | Your `event_id` (1 to 64 characters) | Answered as `duplicates`, not stored again. Retries are safe. |
| A charge | `store` + `transaction_id` | The same charge from two paths (say RevenueCat's webhook and its backfill) is booked once. A refund finds its charge by `transaction_id`. |
| A subscription | `subscription_id` (web), original transaction id (App Store), purchase token (Google Play) | Renewals join the subscription, and credit the ad of its first charge. |
| A store notification | Apple's notification id; Play's token, type and time | Stored once, even when the store sends it again. |
| A purchase link | Original transaction id (iOS), purchase token (Android) | `notifyPurchase` links each once; calling it again is harmless. |
| An identify | The visitor or install and user id pair | Sending the same pair again changes nothing. |

## How the ad networks count each event once

When an event reaches a network twice, from your app or pixel and from Kerdly's server, the network
keeps one copy if both carry the **same event id**.

| Event | Event id Kerdly sends | What your own copy must use |
|---|---|---|
| App trial start / first subscription read from the App Store or Google Play | `<transaction id>:trial_start`, `<transaction id>:subscribe` (the original App Store transaction, or the base Play order) | The same string as `eventID` in the Meta or TikTok SDK call |
| A website's server event (`start_trial`, `subscribe`, `purchase`, …) | Your `event_id` | Your pixel's `eventID` / `event_id`: use your order or charge id for both |
| Other pixel events (`Lead`, `ViewContent`, …) | | `kerdly.eventId("Lead")` on the page, and the same value if your server sends the event too |

If your app also sends conversions to Meta or TikTok through their SDKs, call
`recordNetworkSend` right after each one, with the same event id, so Kerdly can show both sides and
you can see what each network received.

Two rules keep postbacks clean:

1. **Pick one sender per event and network.** If Kerdly's postbacks send `StartTrial` to Meta, turn
   off the app's own `StartTrial` call to Meta, or keep it with the same event id.
2. **Renewals and refunds are not sent to ad networks** by default. Their value is in your reports.

## Test data

- Apps: test builds use a `pk_test_…` key. Sandbox App Store and Google Play test purchases are
  recorded as sandbox.
- Server: send `"environment": "sandbox"` for test-mode charges.
- Live postbacks never send sandbox events.

---

Source: https://kerdly.com/docs/guides/events-and-dedupe. Index of all docs: https://kerdly.com/llms.txt
