# Kerdly docs > Kerdly is profit analytics for subscription apps: it lines up App Store, Google Play and web revenue with ad spend from Meta, TikTok, Apple Ads, Google Ads, Reddit and others, and attributes each install and purchase to the ad that brought it. These docs cover setting up a project and integrating the Kerdly SDKs. # Quickstart Kerdly lines up store revenue with ad spend, so you can see which ads pay back. This page takes you from a new account to a project that fills itself with data. Most steps are a few minutes in the dashboard; adding the SDK is about 15 minutes for a developer. Throughout these docs we use an example product, **Tallybird**, a habit tracker with a weekly and an annual subscription. It has an iOS app, an Android app built with Expo, and a landing page at `tallybird.example`. Swap in your own names. ## How Kerdly is organized | Thing | What it is | Tallybird | |---|---|---| | **Organization** | Your company or studio. Members, roles and billing live here. | Tallybird Labs | | **Project** | One product. Its apps on each platform report side by side. Ad network logins and store notification settings belong to the project. Nothing is shared between projects. | Tallybird | | **App** | One platform of the product. An app's platform is fixed once it is created. | Tallybird iOS, Tallybird Android, Tallybird Web | An Expo or React Native app that ships to both stores is **two Kerdly apps**, one for iOS and one for Android, each with its own SDK key. ## 1. Create your account Kerdly is in early access. Sign up with the link in your invite, or [join the waitlist](https://kerdly.com/#waitlist) to get one. The dashboard lives at [app.kerdly.com](https://app.kerdly.com). ## 2. Create your organization and project After sign-up the dashboard walks you through two forms: 1. **Organization name**: usually your company or studio. You can rename it later. 2. **Your product**: the product name (`Tallybird`) and where it runs: - **iOS app**, with its App Store ID (optional): the number after `id` in the app's App Store URL. - **Android app**, with its package name (optional), for example `com.example.tallybird`. - **Website**, with its address, for example `https://tallybird.example`. **Create the project** makes the project and one app per platform you ticked. A project holds at most one app per platform; a website's web key belongs to the project. Each app then has an **Onboarding** page (first item under Overview) that lists its setup steps, says what each one is waiting on, and tells you what happens next. Prefer to hand this to an AI assistant? Connected to the [Kerdly MCP server](https://kerdly.com/docs/guides/connect-ai-assistant.md), it can create the project and apps, add the SDK to your code and work through the Onboarding steps with you. See [Set up Kerdly with your agent](https://kerdly.com/docs/agents.md#set-up-kerdly-with-your-agent). ## 3. Connect your revenue Revenue comes straight from the stores, so it matches your payouts. - **iOS**: [Connect App Store Connect](https://kerdly.com/docs/get-started/app-store.md). Upload an App Store Connect API key for sales, installs and payouts, and optionally an In-App Purchase key for real-time subscription events. About 5 minutes. - **Android**: [Connect Google Play](https://kerdly.com/docs/get-started/google-play.md). Invite your project's service account in Play Console. No key file. About 5 minutes. - **Web**: connect Paddle or Stripe with a read-only key and Kerdly reads every charge, renewal and refund from them ([Sell on your website](https://kerdly.com/docs/guides/web-checkout.md#4-paddle-or-stripe-connect-it-no-server-code)). Other checkouts report purchases from your server with a server key, or through RevenueCat. A website gets the same P&L as an app; set **Sells** to subscriptions in its settings for Retention and the Dashboard's expected return too. Not sure which setup is yours? Each guide covers one way of selling, start to finish: [Sell on your website](https://kerdly.com/docs/guides/web-checkout.md), [App with App Store and Google Play billing](https://kerdly.com/docs/guides/store-app.md), [App with web payments](https://kerdly.com/docs/guides/app-web-payments.md) and [Web-to-app funnel](https://kerdly.com/docs/guides/web-to-app.md). The last 45 days of App Store sales load within minutes. Installs follow in 24 to 48 hours, once Apple prepares its first analytics reports. ## 4. Connect your ad networks [Connect your ad networks](https://kerdly.com/docs/get-started/ad-networks.md) to bring in spend, clicks and results per campaign. A login is shared by all apps in the project. About 2 minutes per network. ## 5. Add the SDK The SDK reports installs, sign-ups and purchases, and matches each install to the ad click that led to it. | You build with | Use | Guide | |---|---|---| | Expo or React Native | `@kerdly/expo` | [Expo SDK](https://kerdly.com/docs/sdks/expo.md) | | A website or landing page | `@kerdly/web` or the `kerdly.js` snippet | [Web SDK](https://kerdly.com/docs/sdks/web.md) | | Native iOS | `KerdlySDK` (Swift Package Manager) | [iOS SDK](https://kerdly.com/docs/sdks/ios.md) | | Native Android | `com.kerdly:kerdly-sdk` | [Android SDK](https://kerdly.com/docs/sdks/android.md) | [Track the whole funnel](https://kerdly.com/docs/sdks/funnel.md) shows which step, from ad click to refund, comes from the SDK, your server or the stores. Every SDK needs a public key from the dashboard. [SDK keys](https://kerdly.com/docs/sdks.md#keys) explains which key goes where. If a coding agent does the integration for you, point it at [kerdly.com/llms.txt](https://kerdly.com/llms.txt); see [Docs for AI agents](https://kerdly.com/docs/agents.md). ## 6. Check it's working Open the app's **Onboarding** page. Each step is *not started*, *in progress*, *waiting* (on Apple, Google or your release), *needs you* or *done*, with a sentence on what happened and what comes next. After you run a build with the SDK, the SDK step shows when the last event arrived. ## 7. Invite your team Under **Organization → Members**, give marketing and finance their own logins with only the access they need. Roles are defined by your organization, and editing a role updates everyone who has it. --- Source: https://kerdly.com/docs/get-started. Index of all docs: https://kerdly.com/llms.txt # Connect App Store Connect Open the iOS app in the dashboard, go to its **Onboarding** page and choose **Connect the App Store**. The dialog asks what to share; there are two parts. | Part | What it gives you | What you upload | Time | |---|---|---|---| | **Revenue and installs** (required for reports) | Daily sales, proceeds, refunds, downloads and product names, from Apple's reports | An App Store Connect API key (`.p8`) | About 3 minutes | | **Real-time subscription events** (optional) | Trials, renewals and cancellations within minutes instead of the next day's report | An In-App Purchase key (`.p8`) and one URL to paste | About 2 minutes | We use these keys only to read reports and events. They are stored encrypted, never shown again, and you can replace them at any time. ## Revenue and installs: the reports key 1. In App Store Connect, open **Users and Access → Integrations → App Store Connect API**. 2. Generate a **team key** with the **Admin** access level, or **App Manager** plus **Finance**. A Reports-only key can't read product names. 3. Download `AuthKey_XXXX.p8`. Apple lets you download it only once. 4. In the dialog, upload the file. The **Key ID** fills in from the file name. Copy the **Issuer ID** from above the key list (one per team). 5. Pick the app from the list of apps the key's team can see, and enter your **vendor number** (8 digits, under **Payments and Financial Reports**). The App Store ID is fixed to the Kerdly app once it is set: connecting a key checks that the key can see that app. ## Real-time subscription events 1. In App Store Connect, open **Users and Access → Integrations → In-App Purchase** and **Generate key**. Upload `SubscriptionKey_XXXX.p8`. Apple signs each event; this key lets us look up the full transaction behind it. 2. Copy the **Server notification URL** the dialog shows. It looks like `https://hooks.kerdly.com/`. 3. In App Store Connect, open the app's **App Information → App Store Server Notifications** and paste it as the **Production Server URL**, **Version 2**. Already send notifications to your own server? Keep doing so. Your project can forward each raw notification to your own URLs under **Project → Store notifications**. ## What happens next - **Sales and proceeds**: the last 45 days load right away, then every hour from 12:00 to 22:00 UTC. The rest of the past year follows in the background. - **Installs and trials**: in 24 to 48 hours, once Apple makes the first analytics reports. We read them at 06:10 and 16:00 UTC. - **Payouts**: Apple's monthly finance reports, read daily at 14:35 UTC, back to your first release. - **Product names**: read daily at 07:00 UTC. - **Real-time events**: as they happen, with a catch-up every 15 minutes. The Onboarding page shows each of these with its own status. ## Disconnect The same dialog removes either key, or disconnects the App Store entirely. Data already imported stays. Apple doesn't let us revoke a key itself, so the dialog then shows where to revoke it in App Store Connect. Skip that if another tool shares the key. --- Source: https://kerdly.com/docs/get-started/app-store. Index of all docs: https://kerdly.com/llms.txt # Connect Google Play Android revenue and refunds come from Play's earnings reports. There is no key file: each project gets its own Google service account, and you invite it in Play Console. Open the Android app's **Onboarding** page and choose **Connect Google Play**. ## 1. Copy your project's account The dialog shows an email address. Only your project uses this account. ## 2. Invite it in Play Console In Play Console, open **Users and permissions → Invite new users** and paste the email. Under **Account permissions** (not app permissions) turn on: - **View app information and download bulk reports** - **View financial data, orders, and cancellation survey responses** These two let us download the reports and nothing else. We can't publish, reply to reviews or change prices. Give the permissions for the whole account: Play files earnings reports for the developer account, not per app. Permissions given only for one app are the usual reason earnings don't appear. ## 3. Tell us where the reports are - **Package name**: your app's `applicationId`, for example `com.example.tallybird`. It is fixed once the check passes; to track a different app, add a new app. - **Play Console link or developer ID** (optional): any link from your Play Console. It lets the dialog open the right Play Console page for you. - **Earnings reports bucket**: on Play Console's **Download reports → Financial** page, press **Copy Cloud Storage URI** and paste it. We keep only the `pubsite_prod_…` part. A new invite can take a few minutes to apply. If the check says the account can't see the app yet, check that the invite has both permissions and was saved. ## What happens next - Google opens the reports folder to the account, usually within a day. Nothing to do on your side. We check twice a day, and earnings turn on by themselves once the reports read. - The first run loads past months of sales estimates and installs. We read the bucket at 09:25 and 22:25 UTC. - The current month's sales report updates daily, so recent days show gross revenue the next day. - Earnings, net of Google's fee, replace each month's estimates once Google finalizes the payout, early in the following month. ## Real-time subscription notifications (optional) Play's Real-time developer notifications bring trials, renewals and cancellations within minutes. The Android app's Onboarding page links to **Project → Store notifications**, which shows how to turn them on in Play Console. ## Disconnect **Disconnect Google Play** in the same dialog stops reading Play for the app; data already imported stays. Then remove the account in Play Console, unless another app in the project still uses it. --- Source: https://kerdly.com/docs/get-started/google-play. Index of all docs: https://kerdly.com/llms.txt # Connect your ad networks Kerdly reads spend, clicks and the network's own results per campaign, ad set and ad, and puts them next to your store revenue. A network login belongs to the project, so one login serves every app in it. ## Connect a network 1. Open an app's **Onboarding** page and choose **Ad networks**, or go to **Settings → Connections** and press **Add network**. 2. Pick the network you advertise the app on. 3. Sign in, or pick a login the project already has. For Meta, **Continue with Facebook** opens Facebook's own sign-in; a system user token works too. 4. Tick the ad accounts that run this app's campaigns. 5. Choose how much history to load. The first fetch starts right away. The Onboarding step shows the newest day of spend once it lands. ## Networks | Network | What Kerdly reads | |---|---| | Meta | Spend, link clicks and results by campaign, ad set and ad | | TikTok | Spend and clicks by campaign, ad group and ad | | Apple Ads | Spend, taps and installs by campaign, ad group and keyword | | Google Ads | Spend and clicks for app and web campaigns | | Reddit | Spend and clicks by campaign and ad | | ChatGPT Ads | Spend and clicks for web-to-app campaigns | | AppLovin | Spend by campaign and creative | ## Spend is not attribution Connecting a network brings its spend and its own claims. To credit installs and purchases to the ad that actually brought them, add the [SDK](https://kerdly.com/docs/sdks.md) to your app or site. ## When a login needs attention The Onboarding step and the Connections page flag a login that lost a permission, failed a fetch, or whose data is later than its schedule. **Reconnect** signs in again without losing history. --- Source: https://kerdly.com/docs/get-started/ad-networks. Index of all docs: https://kerdly.com/llms.txt # Docs for AI agents Every page of these docs is written for people and for coding agents alike. Agents get the same content as plain Markdown, without navigation or styling. | URL | What it is | |---|---| | [`/llms.txt`](https://kerdly.com/llms.txt) | An index of every docs page with a one-line summary, in the [llms.txt](https://llmstxt.org) format. Start here. | | [`/llms-full.txt`](https://kerdly.com/llms-full.txt) | Every docs page in one Markdown file, for agents that prefer to read everything at once. | | `/docs/.md` | Any single page as Markdown: add `.md` to its address, for example [`/docs/sdks/web.md`](https://kerdly.com/docs/sdks/web.md). | Each page also has a **Copy as Markdown** button, so you can paste it into a chat. ## Hand the integration to your agent Copy one of these prompts into Claude Code, Codex or another coding agent, from the root of your repository. Replace the keys first, or tell the agent where your environment variables live. Each app's **Settings → SDK** has the same prompt with its key filled in (**Copy prompt for your agent**). An agent connected to Kerdly gets it from `kerdly_get_install_instructions`, so it doesn't need you to copy anything (see [below](#set-up-kerdly-with-your-agent)). Each prompt points at an SDK page. Add the guide for how you sell, so the agent knows which events come from the client, which from your server, and how they are deduplicated: | You sell | Add to the prompt | |---|---| | On your website (Stripe, Paddle) | `https://kerdly.com/docs/guides/web-checkout.md` | | In the app, through the App Store and Google Play | `https://kerdly.com/docs/guides/store-app.md` | | In the app, with web payments (Stripe, RevenueCat Web Billing) | `https://kerdly.com/docs/guides/app-web-payments.md` | | A landing page that sends people to the app | `https://kerdly.com/docs/guides/web-to-app.md` | Every guide ends with a checklist the agent can work through. ### Web or landing page ```text Add the Kerdly web SDK to this site. Read https://kerdly.com/docs/sdks/web.md, https://kerdly.com/docs/guides/web-checkout.md and https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them. - Web key: wk_live_REPLACE_ME (public; it may go in client code). - Use the npm package if the site has a build step, otherwise the kerdly.js snippet. - Record a visit on every route change if this is a single-page app. - Mark every link to the App Store or Google Play with data-kerdly-link. - If the site has sign-in, call kerdly.identify(userId) with the same user id the server uses. - If the site sells through Paddle or Stripe and Kerdly reads it (the Web app's Settings › Connections), put that user id on every checkout: Paddle's custom data or Stripe's metadata, under the User id field shown there (kerdly_user_id unless changed). Guest checkouts also pass kerdly_visitor_id from kerdly.visitorId(). Don't send those charges from the server as well. - Otherwise, if the server takes payments, send each trial, first charge, renewal, purchase and refund to POST https://app.kerdly.com/api/v1/s2s/events (the mapping is in web-checkout.md), with the server key from the KERDLY_SERVER_KEY environment variable. Never put the server key in client code. When done, list the files you changed and how to check it works. ``` ### Expo or React Native app ```text Add the Kerdly Expo SDK to this app. Read https://kerdly.com/docs/sdks/expo.md, https://kerdly.com/docs/guides/store-app.md and https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them. - iOS app key: pk_live_REPLACE_ME_IOS. Android app key: pk_live_REPLACE_ME_ANDROID. Put them in EXPO_PUBLIC_KERDLY_IOS_KEY and EXPO_PUBLIC_KERDLY_ANDROID_KEY and pick one with Platform.select. - Add the @kerdly/expo config plugin to the app config. - Call Kerdly.configure once at module scope of the root layout. - Call Kerdly.setUserId after sign-in and with null on sign-out. - Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the purchase flow, with productId, value, currency and transactionId. - Link store purchases with setAppAccountToken and notifyPurchase as the docs show. Don't remove existing analytics or attribution SDKs. When done, list the files you changed, and remind me that the app needs a new development build (Expo Go doesn't run the SDK). ``` ### Native iOS app ```text Add the Kerdly iOS SDK to this app. Read https://kerdly.com/docs/sdks/ios.md, https://kerdly.com/docs/guides/store-app.md and https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them. - iOS app key: pk_live_REPLACE_ME (public; it may go in the app). - Add KerdlySDK with Swift Package Manager, up to the next minor version from 0.1.0. - Call Kerdly.configure once at launch (the App initializer or didFinishLaunching). - Call Kerdly.setUserId after sign-in and with nil on sign-out. - Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the purchase flow, with productId, value, currency and transactionId. - Link App Store purchases with setAppAccountToken and notifyPurchase as the docs show. - Pass every URL the app opens with to Kerdly.handleUrl. Don't remove existing analytics or attribution SDKs. When done, list the files you changed. ``` ### Native Android app ```text Add the Kerdly Android SDK to this app. Read https://kerdly.com/docs/sdks/android.md, https://kerdly.com/docs/guides/store-app.md and https://kerdly.com/docs/guides/events-and-dedupe.md first and follow them. - Android app key: pk_live_REPLACE_ME (public; it may go in the app). - Add com.kerdly:kerdly-sdk:0.1.0 to the app module's dependencies. - Call Kerdly.configure once in Application.onCreate; add metaAppId if the app runs Meta ads. - Call Kerdly.setUserId after sign-in and with null on sign-out. - Send trackRegistration on sign-up, and trackStartTrial, trackSubscribe or trackPurchase from the purchase flow, with productId, value, currency and transactionId. - Link Google Play purchases with setAppAccountToken and notifyPurchase as the docs show. - Pass every URL the app opens with to Kerdly.handleUrl, in onCreate and onNewIntent. Don't remove existing analytics or attribution SDKs. When done, list the files you changed. ``` ## Rules for agents These hold for every integration. They are repeated on the SDK pages. - **Keys**: `pk_` (apps) and `wk_` (web pages) are public and may be committed to client code. `sk_` keys are secret: server-side only, read from an environment variable, never logged. - **One key per platform**: an Expo app has two app keys, one for iOS and one for Android. - **Endpoint**: `https://app.kerdly.com/api`. Leave the SDK default unless told otherwise. - **Configure once**, as early as possible, outside UI components. - **Event names** and prop keys match `^[a-z][a-z0-9_]{0,39}$`. Money is `value` plus a three-letter `currency`. - **Nothing throws.** Don't wrap SDK calls in `try`/`catch` or add retries; the SDK queues and retries on its own. - **The funnel**: click and visit (web SDK), identify (`identify` / `setUserId`), install (app SDK), trial / subscribe / purchase (app SDK, or server events on the web), renewal / cancel / refund (the stores in apps; server events on the web). Same user id everywhere. - **One sender per event.** A store charge comes from the store; a web charge from Paddle or Stripe (when connected), RevenueCat or your server, never two of them. Reuse the charge's id as `event_id`, so retries are dropped as duplicates. - **Name the buyer on web checkouts.** With Paddle or Stripe connected, every checkout carries the same user id the site passes to `identify`, under the Web app's **User id field**. Without it a charge counts but isn't credited to any ad. - **Never invent API calls.** If a page doesn't document a function, it doesn't exist. - **Expo Go doesn't run the native SDK.** Verify on a development build. ## Set up Kerdly with your agent Connect your assistant to the [Kerdly MCP server](https://kerdly.com/docs/guides/connect-ai-assistant.md) and it can do the dashboard side of onboarding too: create the project and its apps, fetch each app's key and install prompt, connect revenue, and check the Onboarding steps, all from the same chat where it edits your code. Tick **project**, **SDK**, **settings** and **connections** when you connect, so it may make those changes. Everything it creates is real: your project, apps and keys, in your organization. A good agent says what it is about to create and waits for your yes; ask yours to. ### The order an agent follows 1. **`kerdly_whoami`**: the organization, its projects and your role. If the product already has a project, use it instead of making another. 2. **`kerdly_create_project`** with the product's name. A project is one product and holds at most one app per platform. 3. **The website**, if there is one: `kerdly_update_project` with `web`, its name and `https` addresses. The project's web key (`wk_live_…`) belongs to the project. 4. **`kerdly_create_app`** once per platform: `ios` (with the App Store ID), `android` (with the package name), `web`. Each app's install key is made with it. 5. **`kerdly_get_install_instructions`** for each app: the key, the snippet and the prompt above with the key filled in. The agent then follows that prompt in your code. 6. **Revenue**: - iOS: `kerdly_set_app_store_credentials` with an App Store Connect API key ([Connect App Store Connect](https://kerdly.com/docs/get-started/app-store.md)). - Android: you invite the project's service account in Play Console from the app's **Onboarding** page ([Connect Google Play](https://kerdly.com/docs/get-started/google-play.md)). - A website on Paddle or Stripe: `kerdly_set_revenue_source_credentials` with `PADDLE_USER_ID_FIELD` (or `STRIPE_USER_ID_FIELD`) first, then the read-only API key, which loads the history. The field is wherever your checkout already puts your user id, for example `orgId`; `kerdly_user_id` if you add one. - What a website sells: `kerdly_update_app_settings` with `MONETIZATION` set to `subscriptions`, `purchases` or `both`. A website counts purchases unless told otherwise; **subscriptions** or **both** turn on its Retention page and the Dashboard's expected return. 7. **Ad networks**: `kerdly_start_oauth_connection` for Meta or TikTok returns a link you open to sign in; then `kerdly_discover_ad_accounts` and `kerdly_attach_ad_account`. 8. **`kerdly_get_onboarding_status`** for each app: every step's status, what it waits on, and `next`, the step to do now, with links to the dashboard pages. ### A prompt for the whole setup Connect your agent first: in Claude Code, `claude mcp add --transport http kerdly https://app.kerdly.com/api/mcp`; in Claude, ChatGPT or Cursor, add `https://app.kerdly.com/api/mcp` as a custom connector ([how](https://kerdly.com/docs/guides/connect-ai-assistant.md)). Then paste this from your product's repository. The dashboard shows the same prompt on the **Add your product** step of sign-up. ```text Set up Kerdly for this product with the Kerdly MCP server, then add the Kerdly SDK to this repository. Read https://kerdly.com/docs/agents.md first and follow it. - From this repository, find the product's name, where it runs (iOS App Store ID, Android package name, website address) and how it takes payments (App Store, Google Play, Paddle, Stripe, RevenueCat or our own server). Ask me for anything you can't find. - Call kerdly_whoami first, and reuse a project if one already exists for this product. - Before you create a project or app, or save a key, tell me what you will do and wait for my yes. - Create the project, its website and one app per platform. Then, for each app, follow the prompt from kerdly_get_install_instructions in this repository. - If the site sells through Paddle or Stripe, find where the checkout already puts our user id (custom data or metadata) and set that field as the User id field before you connect the provider's read-only API key. - When done, show kerdly_get_onboarding_status for each app and tell me which steps are left for me. ``` **Kept for you:** Google Play's invite, signing in to Meta and TikTok, plans and payment, and deleting a project happen in the dashboard, with you there. --- Source: https://kerdly.com/docs/agents. Index of all docs: https://kerdly.com/llms.txt # Sell on your website Use this guide when people buy on your site: a SaaS plan, a membership, an online course, a shop order. There is no app store in the path; your payment provider charges the customer and your server knows about every charge. **Example:** Tallybird sells **Tallybird Web**, a browser version of the habit tracker, with a 7-day trial and a $39.99 annual plan through Stripe on `tallybird.example`. It runs Meta and TikTok ads to `tallybird.example/start`. ## What goes where | Step | Sent by | How | |---|---|---| | Ad click and landing | Browser | The web SDK records the visit with the URL's click id (`fbclid`, `ttclid`, `gclid`) and UTM tags | | More pages | Browser | Visits on every page (single-page apps: `kerdly.visit()` per route) | | Sign-up or sign-in | Browser | `kerdly.identify(userId)` | | Trial, first charge, renewal, one-time purchase, refund | **Your server**, or Paddle / Stripe directly | `POST /v1/s2s/events` from your payment provider's webhook, or the provider connected in Settings → Connections | | Cancel | Nothing needed | A subscription that stops renewing has ended | | Conversions to Meta and TikTok | Kerdly's server | Postbacks, from your server events | Money events come only from your server, or straight from Paddle or Stripe (step 4). The browser can't be trusted with them: an ad blocker, a closed tab or a refresh would lose or double them, and refunds and renewals never happen in the browser at all. ## 1. Set up the project 1. In the dashboard, create the product with **Website** ticked and the site's address. This makes the **Tallybird Web** app. 2. Open the Web app's **Settings → SDK**. Its **web key** (`wk_live_…`) is already made and shown in the snippet to paste. It is public. 3. Under **Server keys and key rotation** on the same page, create a **server key** (`sk_live_…`). It is shown once; put it in your server's secrets as `KERDLY_SERVER_KEY`. ## 2. Add the web SDK to every page ```html ``` Or with npm, see [Web SDK](https://kerdly.com/docs/sdks/web.md#install) (Next.js and single-page apps included). Load it on every page, including the checkout and the pages after it. ## 3. Identify the visitor Call `identify` as soon as you know who the visitor is: after sign-up, after sign-in, and on every page load of a signed-in session (it is sent once per visitor and user). ```ts kerdly.identify(user.id); // your own user id, the same one your server sends ``` This one call is what lets a charge your server reports weeks later find the ad that brought the visitor. **Guest checkout** (no account): pass `kerdly.visitorId()` to your server with the checkout, store it on the order or Stripe customer, and put it on each server event as `visitor_id`. ```ts // when creating the Stripe Checkout Session from the browser await fetch("/api/checkout", { method: "POST", body: JSON.stringify({ plan: "annual", kerdlyVisitorId: window.kerdly?.visitorId() }), }); ``` ```js // server: keep it on the customer, so every later charge carries it const session = await stripe.checkout.sessions.create({ mode: "subscription", line_items: [{ price: "price_tallybird_annual", quantity: 1 }], subscription_data: { trial_period_days: 7, metadata: { kerdly_visitor_id: body.kerdlyVisitorId, user_id: user?.id ?? "" } }, // keep the same two ids on the customer too (customer_creation / customers.update), for refunds success_url: "https://tallybird.example/welcome", }); ``` ## 4. Paddle or Stripe: connect it, no server code If you sell through Paddle or Stripe, Kerdly can read every trial, charge, renewal and refund from the provider itself. Then skip step 5's server code for that provider: Kerdly counts each provider's money from one place only. 1. In the Web app's **Settings → Connections**, open **Payments through Paddle** or **Payments through Stripe** and paste a read-only API key: - Paddle: **Developer tools → Authentication → API keys**, with read access to Transactions, Adjustments and Subscriptions. - Stripe: **Developers → API keys → Create restricted key**, with Read on Charges, Invoices, Subscriptions and Balance. Kerdly loads your whole history right away, then checks for new charges every hour. Set the dialog's **User id field** (step 3) in the same save, since the history is read with it. 2. For charges within seconds, add the webhook the dialog shows (`https://app.kerdly.com/api/paddle?app=…` or `/api/stripe?app=…`) and paste its secret (Paddle's destination secret key, Stripe's signing secret `whsec_…`). Events: Paddle `transaction.completed`, `subscription.created`, `adjustment.created`, `adjustment.updated`; Stripe `charge.succeeded`, `charge.refunded`, `charge.refund.updated`, `customer.subscription.created`. 3. Name the buyer on every checkout. This step is what ties revenue to ads: a charge from Paddle or Stripe comes from their servers, with no cookie, so Kerdly finds the buyer's visit through the user id on the charge, the same id your site passes to `kerdly.identify()` (step 3 above). Put it in Paddle's custom data or Stripe's metadata under the dialog's **User id field**, `kerdly_user_id` unless you change it. If your checkout already stores your own id there (say `orgId` or `account_id`), type that field's name instead and call `identify` with the same id. Changing the field later applies to charges read from then on. Guest checkouts also pass the visitor id: ```js // Paddle.js Paddle.Checkout.open({ items: [{ priceId: "pri_…", quantity: 1 }], customData: { kerdly_visitor_id: window.kerdly?.visitorId(), kerdly_user_id: user?.id }, }); ``` ```js // Stripe Checkout, on your server await stripe.checkout.sessions.create({ mode: "subscription", line_items: [{ price: "price_…", quantity: 1 }], subscription_data: { metadata: { kerdly_visitor_id: body.kerdlyVisitorId, kerdly_user_id: user?.id ?? "" } }, // one-time purchases: payment_intent_data: { metadata: { … } } success_url: "https://tallybird.example/welcome", }); ``` Renewals follow their subscription and refunds their charge, so only the checkout needs the ids. The web app's **Onboarding** page shows **Name the buyer at checkout** as done once your newest charge carries the id, and says how many of the last 30 days' charges do. Reports count what you keep after tax and the provider's fee, in the charge's own currency. The web app's **P&L** reads these charges. When the site sells subscriptions (set **Sells** to subscriptions, or both, in the web app's settings), its **Retention** page and the Dashboard's Expected return and Collected + remaining read them too, each plan renewing on its billing period. A plan change's proration or an extra charge counts as revenue, not as a renewal. Conversions to the ad networks (step 7) still come from server events for now. ## 5. Send money events from your server Send one event per business event, from your payment provider's webhook. These are the events Kerdly reads revenue from: | What happened | `name` | Stripe webhook that tells you | |---|---|---| | A trial started | `start_trial` | `customer.subscription.created` with `status: trialing` | | The first paid charge of a subscription, no trial | `subscribe` | The subscription's first `invoice.paid` with an amount above 0 | | The first paid charge after a trial | `trial_conversion` | The same, for a subscription that had a trial (Stripe marks that invoice `subscription_cycle`) | | Each later charge | `renewal` | Every later `invoice.paid` | | A one-time purchase | `purchase` | `checkout.session.completed` with `mode: payment`, or `charge.succeeded` | | A refund | `refund` | `charge.refunded` | ```js // server/kerdly.js export async function sendKerdlyEvents(events, key = process.env.KERDLY_SERVER_KEY) { const res = await fetch("https://app.kerdly.com/api/v1/s2s/events", { method: "POST", headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" }, body: JSON.stringify({ events }), }); if (!res.ok) throw new Error(`Kerdly ${res.status}`); // let your webhook retry; repeats are safe return res.json(); // { accepted, duplicates, rejected } } ``` ```js // server: Stripe webhook, invoice.paid (adapt field names to your Stripe API version) if (invoice.amount_paid === 0) return; // the $0 invoice that opens a trial const sub = await stripe.subscriptions.retrieve(invoice.subscription); const paidBefore = sub.metadata.kerdly_paid === "1"; const name = paidBefore ? "renewal" : sub.trial_start ? "trial_conversion" : "subscribe"; if (!paidBefore) await stripe.subscriptions.update(sub.id, { metadata: { kerdly_paid: "1" } }); await sendKerdlyEvents([{ event_id: `stripe:${invoice.id}`, // one id per business event name, ts: invoice.status_transitions.paid_at * 1000, user_id: sub.metadata.user_id || null, // the id you passed to identify visitor_id: sub.metadata.kerdly_visitor_id || null, props: { transaction_id: invoice.charge, // the charge id: refunds point at it subscription_id: sub.id, // ties renewals to the first charge product_id: "tallybird_web_annual", product_kind: "subscription", value: invoice.amount_paid / 100, // what the customer paid net_value: netAfterFeesAndTax, // what you keep, same currency currency: invoice.currency.toUpperCase(), store: "stripe", }, }]); ``` ```js // server: Stripe webhook, charge.refunded const customer = await stripe.customers.retrieve(charge.customer); await sendKerdlyEvents([{ event_id: `stripe:refund:${charge.refunds.data[0].id}`, name: "refund", ts: charge.refunds.data[0].created * 1000, user_id: customer.metadata.user_id || null, // the ids you kept on the Stripe customer visitor_id: customer.metadata.kerdly_visitor_id || null, props: { transaction_id: charge.id, // the charge being refunded value: charge.refunds.data[0].amount / 100, currency: charge.currency.toUpperCase(), store: "stripe", }, }]); ``` Rules for every event: - `event_id` is yours and unique per business event. Retrying the same request is safe: a repeat is answered as a duplicate. - Every event needs `user_id` or `visitor_id` (or both). - `transaction_id` with `store` names a charge. Use the provider's charge id, so a refund finds it. - `subscription_id` on every charge of a subscription, so renewals are credited to the first charge's ad. - `value` is what the customer paid; `net_value` what you keep after fees and taxes. Reports count `net_value`; ad networks get `value`. - Test-mode charges: add `"environment": "sandbox"`. Paddle, Lemon Squeezy or your own billing work the same way: map their webhooks onto the six names above and set `store` (`paddle`, or `web` for your own). ## 6. Optional: other events - **Sign-up** as a funnel step: a custom server event, for example `{ "name": "registration", ... }` with `user_id`. It doesn't change revenue. - **Cancellations** aren't needed: reports work from charges, and a subscription without its next `renewal` has ended. If you want them recorded, send a custom event such as `subscription_cancel` with the `subscription_id`. ## 7. Send conversions to Meta and TikTok In the Web app's **Settings → Postbacks**, add Meta (your website's dataset / pixel) or TikTok (your web pixel). By default trials, first subscriptions and purchases from your server are sent, with the click id, `fbc` / `fbp` / `ttp` cookies and IP of the visit that brought the buyer. If the page also fires the Meta or TikTok pixel for the same purchase, give the pixel event the same id as your server event, so the network counts it once: ```js // on the success page, with the id your server used as event_id fbq("track", "Purchase", { value: 39.99, currency: "USD" }, { eventID: "stripe:in_1Q9…" }); ``` ## 8. Check it 1. Open `https://tallybird.example/start?utm_source=meta&utm_medium=paid&campaign_id=test` in a private window, sign up, and buy in Stripe test mode. 2. Your webhook log shows `accepted` for each event. 3. The Web app's **Onboarding** page shows the tag and the server-purchases steps as done; the Dashboard shows the visit and the sandbox charge. ## Agent checklist - [ ] `kerdly.js` (or `createKerdly`) on every page; `visit()` per route in an SPA. - [ ] `identify(userId)` after sign-up and sign-in; guest checkout passes `visitorId()` to the server. - [ ] Paddle / Stripe connected: every checkout puts the same user id in custom data / metadata under the app's **User id field** (default `kerdly_user_id`). - [ ] Server key only on the server, from an environment variable. - [ ] Webhook handler sends `start_trial`, `subscribe` / `trial_conversion`, `renewal`, `purchase`, `refund`, each with `event_id`, `ts`, `user_id` or `visitor_id`, `transaction_id`, `store`, `value`, `currency`, and `subscription_id` for subscriptions. - [ ] No money events from the browser. - [ ] Pixel purchase events use the server event's id. See also [Client events, server events and deduplication](https://kerdly.com/docs/guides/events-and-dedupe.md). --- Source: https://kerdly.com/docs/guides/web-checkout. Index of all docs: https://kerdly.com/llms.txt # App with App Store and Google Play billing 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. | Step | Sent by | How | |---|---|---| | Install, opens, attribution signals | App | The SDK, on its own | | Sign-up, sign-in | App | `setUserId`, `trackRegistration` | | Trial, first charge, one-time purchase | App **and** store | `trackStartTrial` / `trackSubscribe` / `trackPurchase` in seconds; the store's own record follows and is the one counted | | Link the purchase to the install | App | `setAppAccountToken` + `notifyPurchase` | | Renewal, cancel, billing problem, expiry, refund | Store | App Store Server Notifications, Google Play real-time notifications, and daily reports | | Conversions to Meta, TikTok | Kerdly's server | Postbacks, from the store's records | Your server sends nothing in this setup. If you also sell on the web, see [App with web payments](https://kerdly.com/docs/guides/app-web-payments.md). ## 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](https://kerdly.com/docs/get-started/app-store.md). 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/` 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](https://kerdly.com/docs/get-started/google-play.md) 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-`. 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](https://kerdly.com/docs/sdks/ios.md) and [Android SDK](https://kerdly.com/docs/sdks/android.md) pages have the same calls in Swift and Kotlin. Full Expo reference: [Expo SDK](https://kerdly.com/docs/sdks/expo.md). ## 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. ## 6. Link every purchase to the install 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](https://kerdly.com/docs/sdks/expo.md#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. ## 8. Deferred deep links for Meta and TikTok 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 | Network | Campaign type | What to set | |---|---|---| | Meta | App promotion | The deep link from step 8. Spend comes from [connecting Meta](https://kerdly.com/docs/get-started/ad-networks.md). | | TikTok | App promotion | The deep link from step 8, plus deferred deep links on through your rep. | | Apple Ads | Any | Nothing: the SDK reads Apple's attribution token on its own. | | Google Ads | App campaigns | Nothing 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](https://kerdly.com/docs/guides/web-to-app.md). ## 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 `:trial_start` or `: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](https://kerdly.com/docs/guides/events-and-dedupe.md#how-the-ad-networks-count-each-event-once). ## 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 `:trial_start` / `:subscribe` and `recordNetworkSend`. --- Source: https://kerdly.com/docs/guides/store-app. Index of all docs: https://kerdly.com/llms.txt # App with web payments 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](https://kerdly.com/docs/guides/store-app.md): 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 | Where | What to set it to | |---|---| | App SDK | `Kerdly.setUserId(user.id)` | | Web SDK, on your checkout pages | `kerdly.identify(user.id)` | | RevenueCat | `appUserID` = `user.id` (`Purchases.logIn(user.id)`) | | Stripe / Paddle | `user.id` in the customer's and subscription's metadata | | Your server's events | `user_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 purchases | Web purchases | |---|---|---| | Revenue in reports | The iOS and Android apps' Dashboard, Cohorts and P&L | The 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 cohorts | Yes | **Not yet**; being built | | Sent to Meta and TikTok as the app's conversion | Yes | Yes, 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=` - 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](https://kerdly.com/docs/guides/web-checkout.md#4-paddle-or-stripe-connect-it-no-server-code): 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](https://kerdly.com/docs/guides/web-checkout.md#5-send-money-events-from-your-server). 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=` 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. --- Source: https://kerdly.com/docs/guides/app-web-payments. Index of all docs: https://kerdly.com/llms.txt # Web-to-app funnel Use this guide when your ads are **website ads** that end in the app: a landing page or quiz with a "Get the app" button, or an ad that opens your Kerdly link and goes straight to the store. Web campaigns often cost less than app-install campaigns, and Kerdly closes the loop: it sends the app's trials and subscriptions back to Meta and TikTok as **website conversions** from its own server, so the campaigns can optimize for them. **Example:** Tallybird runs a Meta Sales campaign and a TikTok Website conversions campaign to `tallybird.example/start`, a 3-question quiz that ends in "Get Tallybird". ## The pieces | Piece | What it does | You set up | |---|---|---| | **Kerdly link** `https://go.kerdly.com/tallybird` | Records the click, then sends iPhones to the App Store, Android phones to Google Play (with the click in the install referrer), computers to a QR page | Copy it from the project page, **Link** card | | **Landing page** with the web SDK | Records the visit with the ad's click id; its app buttons hand the visitor to the link | `kerdly.js` + `data-kerdly-link` | | **The app** with the SDK | Records the install; Kerdly matches it to the click | [App guide](https://kerdly.com/docs/guides/store-app.md) steps 1 to 7 | | **Postbacks** to the website dataset / pixel | Send the link click and the app's trials and subscriptions to Meta and TikTok as website events | The app's **Settings → Postbacks** | ## 1. Get your Kerdly link Open the project page in the dashboard. The **Link** card shows the project's link, `https://go.kerdly.com/`, and lets you rename it (old names keep working, so running ads never break). One link serves every network, platform and ad: which network and campaign a click came from is read from the click itself. Want it on your own domain, such as `go.tallybird.example`? Ask Kerdly support; we send you the DNS record to add. ## 2. iOS: one custom product page per network (recommended) On iOS the App Store passes nothing from the click to the app, so a web-to-app install can only be matched to its click probabilistically. Give each network its own **custom product page**, and the install names its network for certain: 1. In App Store Connect, create custom product pages for the networks you run: one each for Meta, TikTok, Google and ChatGPT, plus one for other traffic and one for organic. 2. Give each page a **deep link** your app opens, ending in `cpp=web-`: `tallybird://open?cpp=web-meta`, `…cpp=web-tiktok`, `…cpp=web-google`, `…cpp=web-chatgpt`, `…cpp=web-other`, `…cpp=web-organic`. 3. The Kerdly link then sends each network's clicks to its page, with a campaign token (`w2a_meta`, …) that App Analytics counts downloads by. Without these pages the link sends everyone to your default App Store page, and iOS installs are matched probabilistically only. Android needs nothing: the click travels in Google Play's install referrer, and the match is exact. ## 3. Build the landing page ```html …your quiz… Get Tallybird ``` - The SDK records the visit with the URL's `fbclid` / `ttclid` and UTM tags, and writes Meta's `_fbc`. - `data-kerdly-link` records the click and adds the visitor id (`kerdly_v`) to the link, so the link's click continues the visitor's chain: the ad that brought them to the page is the ad the install is credited to. - Use the Kerdly link on every app button, not plain store links: a plain App Store link loses the click. - If your page runs the Meta or TikTok pixel, fire its events with ids from `kerdly.eventId(name)`; Kerdly's server copies use the same ids (see step 6). **Your server redirects to the store instead?** If an app button hits your own endpoint (say `/app-start`) that redirects to the store, either redirect to the Kerdly link, or report each click from your server with `POST /v1/s2s/touchpoints` and turn on **Website postbacks for forwarded clicks** in the project's settings. ## 4. Set up the ads Put the landing page (or the Kerdly link itself, to skip the page) in the ad, with the parameters that name the network and campaign. The **Link** card has them ready to copy for each network. ### Meta Campaign objective **Sales** (or Traffic / Leads), conversion location **Website**, your website dataset (pixel). In the ad, under **Destination**: - **Website URL**: `https://tallybird.example/start` - **URL parameters**: ```text utm_source=meta&utm_medium=paid&campaign_id={{campaign.id}}&adset_id={{adset.id}}&ad_id={{ad.id}}&campaign_name={{campaign.name}}&adset_name={{adset.name}}&ad_name={{ad.name}}&placement={{placement}}&site={{site_source_name}} ``` Put the parameters in **URL parameters**, not in the Website URL: Meta can strip a query typed into the URL itself. Meta adds `fbclid` on its own. ### TikTok Objective **Website conversions**, your web pixel. In the ad, the **Destination URL** takes the URL and the parameters together: ```text https://tallybird.example/start?utm_source=tiktok&utm_medium=paid&campaign_id=__CAMPAIGN_ID__&adgroup_id=__AID__&ad_id=__CID__&campaign_name=__CAMPAIGN_NAME__&adgroup_name=__AID_NAME__&ad_name=__CID_NAME__&placement=__PLACEMENT__ ``` TikTok adds `ttclid` on its own. ### Straight to the store To skip the landing page, use the Kerdly link as the Website URL / Destination URL with the same parameters. The click is recorded at the link and the person lands in the store. ## 5. Add the SDK to the app Follow [App with App Store and Google Play billing](https://kerdly.com/docs/guides/store-app.md), steps 1 to 7: the keys, the stores, the SDK, `setUserId`, and linking purchases. Nothing web-specific is needed in the app. ## 6. Send conversions back from Kerdly's server This is the server tracking: Kerdly, not the browser, tells the networks what happened after the click. 1. In the **app's Settings → Postbacks**, add a **Meta website dataset** destination (your pixel's dataset) and a **TikTok web pixel** destination. Use the same dataset and pixel as the campaign. 2. Map the events: - **Link click** → for example `InitiateCheckout` (Meta) / `ClickButton` (TikTok): sent the moment someone taps through to the store, so the campaign gets a signal right away. - **Trial start** → `StartTrial`, **First subscription** → `Subscribe` (or `Purchase`), from the store's records once the app reports them. 3. Turn the destination live. Each event carries the click's page URL, IP, user agent and the network's own keys (`fbc` / `fbp`, `ttclid` / `ttp`), plus a hashed visitor id as the external id, so the network matches it to the person who clicked. Which installs send website events: | Install matched by | Sent | |---|---| | Android: the Play install referrer carrying the click | Yes | | iOS: the network's custom product page, plus a probabilistic match to the click | Yes | | A probabilistic match alone | Only if you turn on **Website postbacks also for probabilistic installs** in the project's settings | **Deduplication with your pixel.** Website events go out with the id `:`, the same value `kerdly.eventId("")` returns on the page. If the page fires the pixel for the same event with that id, Meta and TikTok count it once. If you don't fire it in the browser, there is nothing to deduplicate. ## 7. Check it 1. On a phone, open `https://tallybird.example/start?utm_source=meta&utm_medium=paid&campaign_id=test`, tap **Get Tallybird**, install the build, and start a sandbox trial. 2. The project's link clicks show the click; the app's Onboarding page shows the install; the install's attribution names `meta` and campaign `test`. 3. The postback destination's activity shows the link click and the trial sent (live destinations skip sandbox purchases; use a test destination to see them). ## Agent checklist - [ ] Web SDK on the landing page; every app button is the Kerdly link with `data-kerdly-link`. - [ ] No plain App Store / Play links on the page. - [ ] Ads carry the network's parameter template (Meta in **URL parameters**, TikTok in the URL). - [ ] iOS: custom product pages with deep links `…cpp=web-`. - [ ] App integrated per the app guide; `notifyPurchase` in place. - [ ] Postbacks: Meta website dataset and TikTok web pixel destinations on the app, link click, trial and subscription mapped. - [ ] Pixel events (if any) use `kerdly.eventId(name)`. --- Source: https://kerdly.com/docs/guides/web-to-app. Index of all docs: https://kerdly.com/llms.txt # 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 | `:trial_start`, `: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 # Manage App Store subscriptions Open your iOS app, then **App Store → Subscriptions**. You see every subscription group and product from App Store Connect, each with its status, its proceeds over the last 30 days and its active subscriptions. You need the App Store connection set up (see [App with App Store and Google Play billing](https://kerdly.com/docs/guides/store-app.md)). Its App Store Connect key must have the **Admin** role, or **App Manager** with **Finance** access. Anyone in your project who can open the App Store tab can look. Only people who can manage the project's connections can change anything. Kerdly keeps a copy for about 10 minutes so it doesn't use up Apple's request limits. Click **Refresh** if you just changed something in App Store Connect. ## Before you create anything - **Product IDs are permanent.** Apple never lets a product ID be reused, even after you delete the product. - **Approved products can't be deleted.** You can remove them from sale in App Store Connect. - **Your first subscription ships with an app version.** Create it here, then choose it on the version in App Store Connect (In-App Purchases and Subscriptions) and submit them together. Once one is approved, later subscriptions can go to review on their own. ## Create a subscription 1. Click **New subscription group** if you don't have one, and add its name in at least one language. 2. In the group, click **New subscription**. Enter a name, the product ID, the billing period, and the display name and description customers see. 3. On the product page, open **Prices** and set a price. 4. Open **Review**, upload a screenshot of your purchase screen and add a note for App Review. 5. Click **Submit for review**. The product page lists anything still missing. ## Change a price Open **Prices** and click **Schedule a price change**. Pick a base storefront and a price, and Kerdly shows Apple's matching price for every other storefront. Untick any you want to leave alone, choose a start date, and decide whether existing subscribers keep their current price on an increase. Scheduled prices are listed above the current ones until they start, and you can remove them. ## Offers - **Introductory offers**: a free trial or lower price for new subscribers. - **Promotional offers**: offers your app presents to current or lapsed subscribers. - **Offer codes**: create an offer, then generate **one-time codes** (download them as a CSV) or a **custom code** you publish. Turning an offer code off is final. - **Win-back offers** are shown here; create and edit them in App Store Connect. ## Everything else - **Languages**: the name and description in each language. - **Availability**: the storefronts where it can be bought. - **Family Sharing**: once on, it can't be turned off. - **Levels**: in a group, the arrows set the order from highest tier to lowest. Customers move up and down between levels. If Apple refuses a change, Kerdly shows why. When a change covers many storefronts, it tells you which ones didn't go through. --- Source: https://kerdly.com/docs/guides/app-store-subscriptions. Index of all docs: https://kerdly.com/llms.txt # Connect an AI assistant Kerdly has an [MCP](https://modelcontextprotocol.io) server. Connect your AI assistant to it and ask questions about your apps in plain language, set up the SDK from your coding agent, or manage campaigns, listings and connections. **The address is the same for every assistant:** ``` https://app.kerdly.com/api/mcp ``` You sign in with your own Kerdly account. There is no key to copy. ## Connect ### Claude In Claude, open **Settings › Connectors**, choose **Add custom connector**, and paste the address. Then press **Connect** and sign in. In Claude Code: ```bash claude mcp add --transport http kerdly https://app.kerdly.com/api/mcp ``` ### ChatGPT On plans that allow custom connectors, open **Settings › Connectors**, create a connector with the address above, and choose OAuth as the authentication. Then sign in when ChatGPT asks. ### Cursor Add this to `~/.cursor/mcp.json`, then sign in when Cursor shows **Needs login** beside the server: ```json { "mcpServers": { "kerdly": { "url": "https://app.kerdly.com/api/mcp" } } } ``` ## What you choose when you connect The consent screen shows the assistant's name, and asks for two things: - **One organization.** A connection acts in one organization only. To work in another, connect again. - **What it may do.** Reading is always included. Changing anything is opt-in, area by area: data, settings, connections, SDK, project, ads, store, and organization administration. ## What it can do An assistant can never do more than you can. Every call runs with your own role in that project, checked at that moment, and the permissions you ticked narrow it further. If your role loses a right, the connection loses it on its next call. | Area | Examples | |---|---| | Reports | Dashboard, P&L, cohorts, LTV, retention, ad performance, SKAN, organic, keywords, CSV export | | Setup | Create projects and apps, onboarding status, SDK install instructions, key and agent prompt, SDK health | | Connections | Connect App Store, Google Play, ad networks, RevenueCat, Paddle and Stripe | | Apple Ads | Campaigns, ad groups, keywords, bids and negatives | | Stores | Listings, translations, product pages, releases, subscriptions | | Links and postbacks | Create links, manage postback destinations and store-notification forwarding | | Organization | Members, invitations, roles, audit log | Reports return totals and up to about 200 rows. For the whole table, ask for the CSV export. ## Set up a new product from your assistant A coding agent connected to Kerdly can onboard a product end to end: create the project and its apps, add the SDK to your code with each app's own key, connect App Store Connect, Paddle or Stripe, and walk the Onboarding steps with you. [Docs for AI agents](https://kerdly.com/docs/agents.md#set-up-kerdly-with-your-agent) lists the order it follows and a prompt to start it with. Tick **project**, **SDK**, **settings** and **connections** on the consent screen for it. **Kept in the dashboard:** deleting a project or organization, transferring ownership, changing or cancelling a plan, paying, and custom link domains. ## Changes that need your go-ahead Changes that spend money, reach Apple or Google, or turn postbacks live take two steps. The first call only shows a preview: the bid changes, the release or subscription to submit, the events about to go live. Nothing changes until the assistant confirms that preview, within 10 minutes. Good assistants show it to you first; ask yours to. ## Credentials An assistant can save store keys, ad network tokens and revenue connector keys for you, and read one back if you have the right to change it. **Those values pass through your AI client and its logs,** so connect only assistants you trust with them, and leave the connections permission unticked if you don't need it. Webhook and server keys that Kerdly stores only as hashes can't be read back; they can only be regenerated, and the new value is shown once. ## Disconnect Open **Organization › Connected apps** in the dashboard and press **Disconnect**. It takes effect on the assistant's next call. Owners and admins see everyone's connections; a member sees their own. Every change an assistant makes appears in **Organization › Audit** with its name. ## Limits Each connection and each organization can make 60 reads and 10 changes a minute. --- Source: https://kerdly.com/docs/guides/connect-ai-assistant. Index of all docs: https://kerdly.com/llms.txt # SDKs overview The Kerdly SDKs measure installs, visits, users, events and purchases, and send them to your project. Kerdly uses them to match each install or sign-up to the ad click that brought it, then to the revenue the stores report. They are open source under the MIT license: [github.com/Kerdly/kerdly-sdk](https://github.com/Kerdly/kerdly-sdk). | Platform | Package | Install | Guide | |---|---|---|---| | Web | `@kerdly/web`, `kerdly.js` | `npm install @kerdly/web` or one ` ``` It records a visit for the page, handles clicks on your app links, and exposes the instance as `window.kerdly`. It loads `async`, so check that `window.kerdly` exists before calling it. `/v1/kerdly.js` is always the newest release, so your site gets fixes without a change on your side. Every release behind that address stays compatible with the one before it; a breaking change would get a new address (`/v2/`). To review each update yourself, pin a release instead. Its file never changes, and the `integrity` attribute makes the browser refuse anything else: ```html ``` Each release's `integrity` value is in its [GitHub release notes](https://github.com/Kerdly/kerdly-sdk/releases) and in [cdn.kerdly.com/versions.json](https://cdn.kerdly.com/versions.json). TypeScript types for `window.kerdly`: ```ts import type { Kerdly } from "@kerdly/web"; declare global { interface Window { kerdly?: Kerdly } } ``` ### Option B: npm ```sh npm install @kerdly/web ``` ```ts import { createKerdly } from "@kerdly/web"; const kerdly = createKerdly({ key: "wk_live_…" }); ``` Create one instance per page load, once, in the browser. Importing the package is safe in server-rendered code; on the server `createKerdly` returns an instance that does nothing. ### Next.js (App Router) A small client component, rendered once in the root layout: ```tsx // app/kerdly.tsx "use client"; import { useEffect } from "react"; import { usePathname } from "next/navigation"; import { createKerdly, type Kerdly } from "@kerdly/web"; let kerdly: Kerdly | null = null; export function getKerdly(): Kerdly { kerdly ??= createKerdly({ key: process.env.NEXT_PUBLIC_KERDLY_WEB_KEY! }); return kerdly; } export function KerdlyTracker() { const pathname = usePathname(); useEffect(() => { getKerdly().visit(); // the first call records the landing page; later calls each new route }, [pathname]); return null; } ``` ```tsx // app/layout.tsx import { KerdlyTracker } from "./kerdly"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ); } ``` `createKerdly` records the first visit itself, and `visit()` ignores a repeat for the same URL, so the effect's first run does no harm. ### Single-page apps The SDK records the landing page once. In a single-page app, call `kerdly.visit()` after each route change. A repeat for the same URL is ignored unless you pass `{ force: true }`. ## Mark your app links Add `data-kerdly-link` to every link that leads to your app: your Kerdly links or store links. ```html Get Tallybird for iPhone Get it on Google Play ``` When one is clicked, the SDK records the click and adds the visitor id to the link, then lets the browser navigate as usual. New-tab and middle clicks work, and links added to the page later are covered. For navigation in your own code: ```ts location.href = kerdly.click("https://apps.apple.com/app/id1234567890"); ``` ## Identify signed-in users If your site has accounts, tell Kerdly who the visitor is after sign-in, so events your server reports for that user are credited to the visitor's ad click: ```ts onAuthStateChanged(auth, (user) => { if (user) kerdly.identify(user.uid); }); ``` `userId` is a string of 1 to 128 characters: the same id your server uses when it reports events. Repeating the call is free; it is sent once. If Kerdly reads your charges from Paddle or Stripe, your checkout puts this same id in Paddle's custom data or Stripe's metadata, under the field set as the Web app's **User id field** (`kerdly_user_id` unless you change it). That is how a charge finds the visit and the ad behind it; see [Sell on your website](https://kerdly.com/docs/guides/web-checkout.md#4-paddle-or-stripe-connect-it-no-server-code). ## Ad pixels If the page also runs the Meta or TikTok pixel, give pixel events an id from `eventId`. Kerdly sends its own copy of the event under the same id, so the network counts it once: ```js fbq("track", "Lead", {}, { eventID: kerdly.eventId("Lead") }); ttq.track("ViewContent", {}, { event_id: kerdly.eventId("ViewContent") }); ``` For a purchase, use your order id as the pixel's `eventID` instead, and send the same id as the server event's `event_id` (see [deduplication](https://kerdly.com/docs/guides/events-and-dedupe.md)). ## Report purchases from your server Which payment event maps to which Kerdly event, with a Stripe example, is in [Track the whole funnel](https://kerdly.com/docs/sdks/funnel.md#setup-2-a-website-that-sells-on-the-web), and the full Stripe walkthrough with webhooks and refunds is in [Sell on your website](https://kerdly.com/docs/guides/web-checkout.md). On the web, trials and purchases come from your server, which knows they really happened, or straight from Paddle or Stripe when you [connect them](https://kerdly.com/docs/guides/web-checkout.md#4-paddle-or-stripe-connect-it-no-server-code) (then skip this section for that provider). Your server sends them with the Web app's **server key** to `POST /v1/s2s/events`. Kerdly joins each one to the visitor you identified and, if you turned on postbacks, forwards it to your ad networks. Get the key from the Web app's **Settings → SDK → Server keys and key rotation**. It is shown once; keep it in your server's secrets. ```sh curl https://app.kerdly.com/api/v1/s2s/events \ -H "Authorization: Bearer $KERDLY_SERVER_KEY" \ -H "Content-Type: application/json" \ -d '{ "events": [{ "event_id": "ch_3Q9tallybird0001", "name": "subscribe", "ts": 1793900000000, "user_id": "user_8f2k1", "props": { "product_id": "tallybird_pro_annual", "transaction_id": "ch_3Q9tallybird0001", "value": 39.99, "net_value": 36.12, "currency": "USD", "store": "stripe", "product_kind": "subscription", "subscription_id": "sub_1Q9tallybird" } }] }' ``` | Field | Required | | |---|---|---| | `event_id` | yes | Your id for the event, 1 to 64 characters. A repeat is answered as a duplicate, so retries are safe. | | `name` | yes | `start_trial`, `subscribe`, `trial_conversion`, `renewal`, `purchase`, `refund`, or a custom name. | | `ts` | yes | When it happened, in milliseconds since the epoch. | | `user_id`, `visitor_id` | one of them | The id you passed to `identify`, or `kerdly.visitorId()` from the page. | | `props` | no | `value` (what the customer paid), `net_value` (what you keep after fees and taxes, same currency), `currency`, `product_id`, `transaction_id`, `store` (`stripe`, `paddle`, … or `web`), `product_kind`, `subscription_id`. A `refund` needs the `transaction_id` of the charge it refunds. | | `environment` | no | `production` (default) or `sandbox`. | Up to 100 events per request. The answer lists each event as accepted, duplicate or rejected: ```json { "accepted": ["ch_3Q9tallybird0001"], "duplicates": [], "rejected": [] } ``` A rejected event carries its `index` and a `reason`: `invalid_event`, `invalid_name`, `reserved_name`, `invalid_props`, `invalid_ts`, `missing_user` or `invalid_overrides`. ## Options | Option | Snippet attribute | Default | | |---|---|---|---| | `key` | `data-key` | required | The project's web key (`wk_live_…`). The SDK refuses a secret `sk_` key. | | `endpoint` | `data-endpoint` | `https://app.kerdly.com/api` | Where data is sent. | | `cookieDomain` | `data-cookie-domain` | your site's main domain | Set it if the site is on a shared hosting domain (`*.vercel.app`, `*.github.io`) or an unusual country domain. | | `visitorCookie` | `data-visitor-cookie` | `kerdly_vid` | Name an existing first-party id cookie to reuse it. It must be readable by JavaScript (not `HttpOnly`). | | `autoVisit` | | `true` | Record a visit when the SDK starts. | | `autoDecorate` | `data-auto-decorate` | `a[data-kerdly-link]` | Which links are app links: a CSS selector, or `false` to turn it off. | | `ipv6EchoUrl` | `data-ipv6-echo-url` | on | Looks up the visitor's public IPv6 address once per tab. `null` (or an empty attribute) turns it off. | ## API No method throws. | Method | Returns | | |---|---|---| | `kerdly.visit(options?)` | `boolean` | Records a visit to the current page. A repeat for the same URL is ignored unless `{ force: true }`. | | `kerdly.click(url)` | `string` | Records a click on an app link and returns the URL to navigate to. | | `kerdly.decorate(url)` | `string` | Returns the URL with the visitor id added, without recording a click. | | `kerdly.identify(userId)` | `boolean` | Links this visitor to your own user id. | | `kerdly.eventId(name)` | `string` | An event id to share between a browser pixel event and the same event from your server. | | `kerdly.visitorId()` | `string` | The visitor id. | ## Content-Security-Policy If your site sends a CSP, allow `https://cdn.kerdly.com` in `script-src` (snippet only), and `https://app.kerdly.com` and `https://api6.ipify.org` (the IPv6 lookup) in `connect-src`. ## Cookies and storage | Name | Where | Lifetime | Purpose | |---|---|---|---| | `kerdly_vid` (or your `visitorCookie`) | first-party cookie | 400 days (7 days in Safari for script-set cookies) | The visitor id | | `_fbc` | first-party cookie | 90 days | Meta's click cookie, written when the URL has an `fbclid`, the same way Meta's pixel does | | `kerdly_uid` | `localStorage` | until cleared | Remembers the last `identify`, so it isn't sent twice | | `kerdly_ip6` | `sessionStorage` | the tab session | The result of the IPv6 lookup | The SDK reads Meta's `_fbp` and TikTok's `_ttp` cookies but never writes them. Cookies are `SameSite=Lax`, and `Secure` on https pages. ## Consent Nothing is stored or sent before `createKerdly` runs or the snippet loads. On a page that waits for consent, load the snippet or call `createKerdly` after the visitor agrees. To start fully passive and decide yourself when to send: ```ts const kerdly = createKerdly({ key: "wk_live_…", autoVisit: false, autoDecorate: false, ipv6EchoUrl: null }); ``` Each visit or click sends the page URL and title, the referrer, the visitor id, the Meta and TikTok cookies above, the browser's user agent (from 0.1.1), and the visitor's public IPv6 address when available. ## Check it's working 1. Open your page with a test campaign tag, for example `?utm_source=test&utm_campaign=docs_check`. 2. In the browser's network tab, look for a `POST` to `app.kerdly.com/api/v1/web/touch` answered with a success status. 3. In the dashboard, the Web app's **Onboarding** page shows the tag step with the time of the last visit. ## Troubleshooting - Warnings in the browser console start with `[Kerdly]`. - The visitor id changes on every page load: the cookie named in `visitorCookie` is `HttpOnly`, or the browser refused `cookieDomain`. Use the default cookie or fix the domain. - Questions or problems: [open an issue](https://github.com/Kerdly/kerdly-sdk/issues) or contact Kerdly support. Never post your keys. --- Source: https://kerdly.com/docs/sdks/web. Index of all docs: https://kerdly.com/llms.txt # Expo SDK `@kerdly/expo` runs the native Kerdly SDKs for iOS and Android inside your Expo or React Native app. It adds a config plugin, captures deep links on its own, and gives you one TypeScript API for both platforms. ## Requirements - Expo SDK 52 or newer (developed against SDK 57), or a bare React Native app with Expo modules. - A development or production build: `npx expo prebuild`, `npx expo run:ios`, or EAS Build. **Expo Go and web don't contain the native code**; there every call does nothing and you get one development warning. - iOS 15 or newer; Android 7.0 (API 24) or newer. ## Before you start An Expo app that ships to both stores is **two Kerdly apps**, Tallybird iOS and Tallybird Android, each with its own app key. Create both apps in your project (the product form at sign-up does this when you tick iOS and Android), then open each app's **Settings → SDK**: its app key is already made and shown in the code to paste. | Kerdly app | Bundle id / package | Key | |---|---|---| | Tallybird iOS | `com.example.tallybird` | `pk_live_ios…` | | Tallybird Android | `com.example.tallybird` | `pk_live_and…` | App keys are public; they ship inside your app. Never put a server key (`sk_…`) in the app; the SDK refuses it. ## Install ```sh npx expo install @kerdly/expo ``` Add the config plugin to `app.json` (or `app.config.ts`): ```json { "expo": { "plugins": [ [ "@kerdly/expo", { "metaAppId": "1234567890123456", "userTrackingPermission": "Lets us measure which of our ads brought you to Tallybird." } ] ] } } ``` Then rebuild the native projects: `npx expo prebuild` (or your next EAS build). | Plugin option | Platform | What it does | |---|---|---| | `metaAppId` | Android | Your Facebook app id. Turns on the Meta Install Referrer read, which matches installs from Meta ads. | | `userTrackingPermission` | iOS | Sets `NSUserTrackingUsageDescription`, the App Tracking Transparency prompt text. Needed for `requestTrackingAuthorization()`. | | `skanEndpoint` | iOS | Sets `NSAdvertisingAttributionReportEndpoint`, so copies of SKAdNetwork postbacks reach Kerdly. Use the address on the iOS app's **Settings → SKAdNetwork** page. | The plugin only sets the keys it is given and never removes an Info.plist key, so values you set in `ios.infoPlist` survive. Running it twice changes nothing. The Android side adds the `INTERNET` and `com.google.android.gms.permission.AD_ID` permissions and `` entries for the Facebook, Instagram and Facebook Lite apps (Meta Install Referrer). An app that must not read the advertising id blocks `AD_ID` with Expo's `android.blockedPermissions` and passes `collectAdvertisingId: false`. ## Configure Call `configure` once, as early as possible: at module scope of your root file (`app/_layout.tsx` with Expo Router, `App.tsx` otherwise), not inside a component. Pick the key by platform: ```ts // app/_layout.tsx import { Platform } from 'react-native'; import { Kerdly } from '@kerdly/expo'; Kerdly.configure({ key: Platform.select({ ios: process.env.EXPO_PUBLIC_KERDLY_IOS_KEY!, // pk_live_… of Tallybird iOS android: process.env.EXPO_PUBLIC_KERDLY_ANDROID_KEY!, // pk_live_… of Tallybird Android })!, }); ``` A second `configure` is ignored. Calls made before `configure` are held and run after it. | Option | Default | | |---|---|---| | `key` | required | The app's public key: `pk_live_…`, or `pk_test_…` for test builds. | | `endpoint` | `https://app.kerdly.com/api` | Change it only if Kerdly support asks you to. | | `environment` | `'auto'` | `'production'`, `'sandbox'` or `'development'`. `'auto'` lets the native SDK decide from the build. | | `collectAdvertisingId` | `true` | Read the IDFA (only when the user allowed tracking) or the GAID. | | `skanWriter` | `false` | iOS: let Kerdly write SKAdNetwork conversion values. Only one SDK in an app should write them. | | `metaAppId` | the plugin's | Android: overrides the plugin's `metaAppId`. | | `logLevel` | `'warn'` | `'none'`, `'error'`, `'warn'`, `'info'` or `'debug'`. | | `autoDeepLinks` | `true` | Forward React Native `Linking` URLs to the SDK. | No function throws and no promise rejects. Invalid input is dropped with a development warning. ## Users After sign-in, set your own user id; it is attached to every later event. Clear it on sign-out. ```ts Kerdly.setUserId(user.id); Kerdly.setUserId(null); ``` ## Standard events What the app sends and what comes from the stores is laid out step by step in [Track the whole funnel](https://kerdly.com/docs/sdks/funnel.md#setup-1-an-app-that-sells-through-the-stores). The full setup, with store notifications, deferred deep links and postbacks, is in [App with App Store and Google Play billing](https://kerdly.com/docs/guides/store-app.md); if you also sell on the web, see [App with web payments](https://kerdly.com/docs/guides/app-web-payments.md). Send these when they happen. Every field is optional, and a malformed field is dropped with a warning, never the whole event. ```ts Kerdly.trackRegistration({ method: 'apple' }); Kerdly.trackStartTrial({ productId: 'tallybird_pro_weekly', value: 0, currency: 'USD', transactionId }); Kerdly.trackSubscribe({ productId: 'tallybird_pro_annual', value: 39.99, currency: 'USD', transactionId, properties: { paywall: 'onboarding_v2' }, }); Kerdly.trackPurchase({ productId: 'tallybird_streak_freeze', value: 1.99, currency: 'USD', quantity: 1, transactionId }); ``` - `value` is what the user paid, in `currency` (three letters, ISO 4217). Without a valid currency the value is dropped. - `productId` and `transactionId` are cut to 128 characters, `method` to 64. - `properties` adds custom props. A key that is one of the event's typed fields (`value`, `product_id`, …) is dropped: set it through the typed field. ## Custom events ```ts Kerdly.track('habit_created', { category: 'fitness', reminders: true }); ``` Names and prop keys match `^[a-z][a-z0-9_]{0,39}$`. At most 25 props; values are strings (cut to 256 characters), finite numbers or booleans. ## Link purchases to the install Renewals and refunds come from the stores. To credit them to the right campaign, link each store purchase to the install. 1. Tell the SDK the account token your purchases carry: on iOS the StoreKit `appAccountToken` (a UUID), on Android the Play `obfuscatedAccountId`. 2. After each completed purchase, pass the transaction to `notifyPurchase`. ```ts import { Platform } from 'react-native'; import { Kerdly } from '@kerdly/expo'; Kerdly.setAppAccountToken(accountToken); // in your purchase callback if (Platform.OS === 'ios') { Kerdly.notifyPurchase({ originalTransactionId: tx.originalTransactionId, transactionId: tx.transactionId, productId: tx.productId, appAccountToken: tx.appAccountToken, }); } else { Kerdly.notifyPurchase({ purchaseToken: tx.purchaseToken, orderId: tx.orderId, products: [tx.productId], }); } ``` Each transaction is linked once; calling it again is harmless. On iOS, `Kerdly.notifyPurchase()` with no argument (after a restore, say) links the current entitlements. ### With Superwall ```tsx import { useEffect } from 'react'; import { Platform } from 'react-native'; import { useSuperwallEvents, useUser } from 'expo-superwall'; import { Kerdly } from '@kerdly/expo'; export function KerdlySuperwallBridge() { const { user } = useUser(); const alias = user?.aliasId; // "$SuperwallAlias:3F2504E0-4F89-41D3-9A0C-0305E82C3301" useEffect(() => { if (!alias) return; const aliasUuid = alias.replace(/^\$SuperwallAlias:/, ''); Kerdly.setAppAccountToken(Platform.OS === 'ios' ? aliasUuid : alias); Kerdly.setPartnerIds({ superwall_alias: alias }); }, [alias]); useSuperwallEvents({ onSuperwallEvent: ({ event }) => { if (event.event !== 'transactionComplete') return; const tx = event.transaction; if (Platform.OS === 'ios') { Kerdly.notifyPurchase({ originalTransactionId: tx?.originalTransactionIdentifier, transactionId: tx?.storeTransactionId, productId: event.product.productIdentifier, appAccountToken: tx?.appAccountToken, }); } else if (tx?.purchaseToken) { Kerdly.notifyPurchase({ purchaseToken: tx.purchaseToken, orderId: tx.storeTransactionId, products: [event.product.productIdentifier], }); } }, }); return null; } ``` Render it inside ``. ## Deep links With `autoDeepLinks: true` (the default), the SDK receives the URL that opened the app and every later link from React Native `Linking`. `expo-dev-client` launcher URLs are skipped. Don't also call `handleUrl` for those URLs. For a link that never reaches `Linking`, such as a deferred link from another SDK: ```ts const link = await Kerdly.handleUrl(url); // { url, cpp, ppid, clickId, visitId, campaignIds }, each null when absent ``` ## Attribution Read which network and campaign brought the install. It is `null` until Kerdly decides, and `state` says whether the answer is `provisional` or `final`. ```tsx import { useEffect, useState } from 'react'; import { Kerdly, type KerdlyAttribution } from '@kerdly/expo'; export function useAttribution() { const [attribution, setAttribution] = useState(null); useEffect(() => { const sub = Kerdly.addAttributionListener(setAttribution); return () => sub.remove(); }, []); return attribution; // attribution?.network: 'meta' | 'tiktok' | 'apple_ads' | 'organic' | … } ``` ## Consent and App Tracking Transparency ```ts Kerdly.setConsent({ analytics: true, ads: false }); ``` - `analytics: false` keeps only the SDK's own events (installs and opens). - `ads: false` stops reading the IDFA or GAID. - An omitted flag keeps its value. The SDK never shows the iOS tracking prompt on its own. To ask (after setting `userTrackingPermission` in the plugin): ```ts const status = await Kerdly.requestTrackingAuthorization(); // 'authorized' | 'denied' | 'restricted' | 'not_determined'; 'not_applicable' on Android ``` ## Recording sends to ad networks If the app also reports conversions to Meta or TikTok through their SDKs, record each send with the same event id the network gets, so Kerdly can show both sides: ```ts Kerdly.recordNetworkSend({ network: 'meta', event: 'StartTrial', eventId, value: 0, currency: 'USD' }); ``` ## API | Call | Does | |---|---| | `await Kerdly.configure(options)` | Starts the native SDK. | | `Kerdly.setUserId(id \| null)` | Your user id, attached to every later event. | | `Kerdly.track(name, props?)` | A custom event. | | `Kerdly.trackRegistration({ method?, properties? })` | Standard event `registration`. | | `Kerdly.trackStartTrial({ productId?, value?, currency?, transactionId?, properties? })` | Standard event `start_trial`. | | `Kerdly.trackSubscribe({ productId?, value?, currency?, transactionId?, properties? })` | Standard event `subscribe`. | | `Kerdly.trackPurchase({ productId?, value?, currency?, quantity?, transactionId?, properties? })` | Standard event `purchase`. | | `Kerdly.setConsent({ analytics?, ads? })` | Consent flags. | | `await Kerdly.handleUrl(url)` | Records a deep link and returns what it carried, or `null`. | | `Kerdly.setAppAccountToken(token \| null)` | iOS `appAccountToken`; Android `obfuscatedAccountId`. | | `Kerdly.setPartnerIds(ids)` | Ids other SDKs own; an empty value removes a key. | | `Kerdly.notifyPurchase(purchase?)` | Links a store purchase to the install. | | `Kerdly.recordNetworkSend(send)` | A conversion the app sent to an ad network itself. | | `await Kerdly.getAttribution()` | The install's attribution, or `null` until known. | | `Kerdly.addAttributionListener(fn)` | Calls `fn` now (when known) and on every change. Returns `{ remove() }`. | | `await Kerdly.requestTrackingAuthorization()` | iOS ATT prompt; `'not_applicable'` on Android. | | `await Kerdly.flush()` | Sends the queue now. | | `await Kerdly.getInstallId()` | The install id, or `null` before `configure`. | ## Data and privacy The native SDKs do the collecting. For your App Store and Google Play privacy answers, see [iOS: Data and privacy](https://kerdly.com/docs/sdks/ios.md#data-and-privacy) and [Android: Data and privacy](https://kerdly.com/docs/sdks/android.md#data-and-privacy). The SDK never collects names, email addresses, phone numbers, location or clipboard contents. ## Check it's working 1. Set `logLevel: 'debug'` and run a development build on a device or simulator. 2. Look for `[Kerdly]` lines in the Xcode console or logcat: the SDK logs what it sends and any error Kerdly answers with. 3. In the dashboard, the app's **Onboarding** page shows the SDK step with the time of the last event. Check both Tallybird iOS and Tallybird Android. ## Troubleshooting - Nothing happens in Expo Go: expected. Use a development build. - Kerdly answers `bundle_mismatch`: the key belongs to the other platform's Kerdly app, or the bundle id doesn't match the app's. Check the `Platform.select`. - Kerdly answers `bad_key` or `key_revoked`: the key was mistyped or revoked; create a new one under Settings → SDK. - Questions or problems: [open an issue](https://github.com/Kerdly/kerdly-sdk/issues) or contact Kerdly support. Never post your keys. --- Source: https://kerdly.com/docs/sdks/expo. Index of all docs: https://kerdly.com/llms.txt # iOS SDK `KerdlySDK` measures installs, users, events and purchases in a native iOS app and sends them to your Kerdly project. Kerdly matches each install to the ad that brought it, then to the revenue the App Store reports. Swift, no third-party dependencies, open source: [github.com/Kerdly/kerdly-sdk](https://github.com/Kerdly/kerdly-sdk/tree/main/ios). Building with Expo or React Native? Use the [Expo SDK](https://kerdly.com/docs/sdks/expo.md) instead: it carries this same iOS code. ## Requirements - iOS 15 or newer, Swift 5.9 or newer, Xcode with Swift Package Manager. - The app's iOS app in your Kerdly project. The product form at sign-up makes it when you tick **iOS app**; with its App Store ID, purchases and installs line up with App Store Connect. ## Before you start Open the iOS app's **Settings → SDK** in the dashboard. Its **app key** (`pk_live_…`) is already made and shown in the code to paste. App keys are public; they ship inside your app. Use a `pk_test_…` key for test builds, so their traffic stays out of your reports. Never put a server key (`sk_…`) in the app; the SDK refuses it. Each app key belongs to one bundle id. The SDK sends it with every request, and Kerdly refuses a key used by another app. ## Install In Xcode: **File → Add Package Dependencies…**, enter `https://github.com/Kerdly/kerdly-sdk`, choose **Up to Next Minor Version** from `0.1.0`, and add `KerdlySDK` to your app target. In a `Package.swift`: ```swift .package(url: "https://github.com/Kerdly/kerdly-sdk", .upToNextMinor(from: "0.1.0")), // … .product(name: "KerdlySDK", package: "kerdly-sdk") ``` The SDK is distributed through Swift Package Manager only, not CocoaPods. Until 1.0 a minor version may change the API, so "Up to Next Minor" is the safe rule. ## Configure Call `configure` once, as early as possible: in `application(_:didFinishLaunchingWithOptions:)`, or your SwiftUI `App` initializer. It returns at once; the work happens in the background. ```swift import KerdlySDK @main struct TallybirdApp: App { init() { Kerdly.configure(KerdlyOptions(key: "pk_live_…")) // Tallybird iOS's app key } var body: some Scene { WindowGroup { ContentView() } } } ``` ```swift // UIKit func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { var options = KerdlyOptions(key: "pk_live_…") options.logLevel = .warn Kerdly.configure(options) return true } ``` | Option | Default | | |---|---|---| | `key` | required | The app's public key: `pk_live_…`, or `pk_test_…` for test builds. | | `endpoint` | `https://app.kerdly.com/api` | Change it only if Kerdly support asks you to. | | `environment` | `.auto` | `.production`, `.sandbox` or `.development`. `.auto` detects it from the build. | | `collectAdvertisingId` | `true` | Read the IDFA when the user allowed tracking. | | `skanWriter` | `false` | Let Kerdly write SKAdNetwork conversion values. See [SKAdNetwork](#skadnetwork). | | `logLevel` | `.warn` | `.none`, `.error`, `.warn`, `.info` or `.debug`. | Every other method is safe from any thread, before or after `configure` (earlier calls run once the SDK has started), and never throws. ## Users and consent After sign-in, set your own user id; it is attached to every later event. Clear it on sign-out. Use the same id your server and RevenueCat use. ```swift Kerdly.setUserId(user.id) // after sign-in Kerdly.setUserId(nil) // on sign-out Kerdly.setConsent(analytics: true, ads: true) // reflect your consent screen ``` - `analytics: false` stops your custom and standard events; installs and opens are still counted. - `ads: false` stops reading the advertising identifier and other ad-measurement signals. ## Standard events Send these at the moments ad networks optimize on. Every argument is optional. ```swift Kerdly.trackRegistration(method: "apple") Kerdly.trackStartTrial(productId: "tallybird_pro_weekly", value: 0, currency: "USD", transactionId: tx) Kerdly.trackSubscribe(productId: "tallybird_pro_weekly", value: 7.99, currency: "USD", transactionId: tx) Kerdly.trackPurchase(productId: "streak_freeze_5", value: 4.99, currency: "USD", quantity: 1, transactionId: tx) ``` - `value` is what the user paid, in `currency` (`0` for a free trial). - `currency` is a three-letter ISO 4217 code. A `value` without a valid currency is dropped. - `quantity` is a whole number of 1 or more. - `properties:` adds your own fields under the custom-event rules below. These events tell the ad networks early. The revenue in your reports comes from the App Store itself, so renewals and refunds need nothing from the app (see [Client events, server events and deduplication](https://kerdly.com/docs/guides/events-and-dedupe.md)). ## Custom events ```swift Kerdly.track("quiz_completed", properties: ["score": 42, "level": "hard"]) ``` - Names and property keys: lowercase letters, digits and `_`, starting with a letter, at most 40 characters. - At most 25 properties. Values are strings (up to 256 characters), numbers or booleans. - An invalid name drops the event; an invalid property is dropped on its own. With `logLevel = .debug` the console says why. ## Link purchases to the install Renewals and refunds come from the App Store. To credit them to the right campaign, link each purchase to the install: 1. Tell the SDK the `appAccountToken` your purchases carry (a UUID; with Superwall, the UUID in the user's alias). 2. After each completed purchase, pass the transaction to `notifyPurchase`. ```swift Kerdly.setAppAccountToken(accountTokenUUID) // in your purchase callback (StoreKit 2 Transaction) Kerdly.notifyPurchase(KerdlyPurchase(originalTransactionId: String(tx.originalID), transactionId: String(tx.id), productId: tx.productID, appAccountToken: tx.appAccountToken)) // after a restore, with no argument: links the current entitlements Kerdly.notifyPurchase() ``` Each transaction is linked once; calling it again is harmless. For the whole store setup (App Store Connect, real-time notifications), see [Sell in a store app](https://kerdly.com/docs/guides/store-app.md). If your app also sends conversions to Meta or TikTok itself, record each send with the event id the network receives, so Kerdly can show both sides: ```swift Kerdly.recordNetworkSend(KerdlyNetworkSend(network: "meta", event: "StartTrial", eventId: eventId, value: 0, currency: "USD")) ``` Ids from other SDKs can be attached with `Kerdly.setPartnerIds(["superwall_alias": alias])`. ## Deep links Pass every URL your app is opened with to `Kerdly.handleUrl`. It records the open and returns the Kerdly parameters it found; your app keeps its own navigation. Custom schemes and universal links both work, including [Kerdly links](https://kerdly.com/docs/guides/web-to-app.md). ```swift // SwiftUI .onOpenURL { Kerdly.handleUrl($0) } // UIApplicationDelegate func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { Kerdly.handleUrl(url) return true } // UISceneDelegate func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { connectionOptions.urlContexts.forEach { Kerdly.handleUrl($0.url) } connectionOptions.userActivities.compactMap(\.webpageURL).forEach { Kerdly.handleUrl($0) } } func scene(_ scene: UIScene, openURLContexts contexts: Set) { contexts.forEach { Kerdly.handleUrl($0.url) } } func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { if let url = userActivity.webpageURL { Kerdly.handleUrl(url) } } ``` `handleUrl` returns a `KerdlyDeepLink` (`url`, `cpp`, `ppid`, `clickId`, `visitId`, `campaignIds`) or nil. ## Attribution ```swift Kerdly.onAttribution { attribution in // on the main thread: now if known, and again if it changes print(attribution.network, attribution.campaign ?? "") } let current = Kerdly.attribution // nil until known let installId = Kerdly.installId // give it to your backend to tie accounts to installs ``` `Kerdly.flush()` sends queued events now, for example before a UI test ends. ## App Tracking Transparency The SDK never shows the tracking prompt on its own. To ask: ```swift let status = await Kerdly.requestTrackingAuthorization() ``` Add `NSUserTrackingUsageDescription` to your Info.plist first; without it the SDK doesn't ask and returns the current status. The prompt appears once the app is active, and the answer is recorded. ## SKAdNetwork Keep your `SKAdNetworkItems`, and `NSAdvertisingAttributionReportEndpoint` if you receive postback copies, in Info.plist. To have Kerdly write conversion values, set `options.skanWriter = true`. Only one SDK in an app should write conversion values, so turn off any other writer in the same release. ## Data and privacy What the SDK sends, for your App Store privacy answers: | Data | When | |---|---| | An install id generated by the SDK, and the IDFV | always | | Device model, OS version, language, time zone, app version | always | | Apple Ads attribution token and the App Store's install record (AppTransaction) | once per install | | App events you track | with `analytics` consent | | Purchase identifiers | when you call `notifyPurchase` | | IDFA | only with tracking authorized, `ads` consent and `collectAdvertisingId` | | Public IPv6 address | with `ads` consent | | The user id you set | when you call `setUserId` | | The IDFA (when allowed), sent to Meta and TikTok to ask which ad led to the install | only with deferred deep links on in your Kerdly project, and `ads` consent | The SDK never collects names, email addresses, phone numbers or clipboard contents, and never reads location services (GPS). It ships a privacy manifest (`PrivacyInfo.xcprivacy`) that Xcode adds to your app's privacy report. ## Check it's working 1. Set `options.logLevel = .debug` and run the app on a device or simulator. 2. Filter the Xcode console for `[Kerdly]`: the SDK logs what it sends and any error Kerdly answers with. 3. In the dashboard, the iOS app's **Onboarding** page shows the SDK step with the time of the last event. Events arrive within a minute; `Kerdly.flush()` sends at once. ## Troubleshooting - Kerdly answers `bundle_mismatch`: the key belongs to another Kerdly app, or the bundle id doesn't match this app's. - Kerdly answers `bad_key` or `key_revoked`: the key was mistyped or revoked; create a new one under **Settings → SDK**. - Questions or problems: [open an issue](https://github.com/Kerdly/kerdly-sdk/issues) or contact Kerdly support. Never post your keys. ## Agent checklist - [ ] `KerdlySDK` added with Swift Package Manager, up to the next minor version from `0.1.0`. - [ ] `Kerdly.configure` once at launch, with the iOS app's `pk_live_` key (never an `sk_` key). - [ ] `setUserId` after sign-in and `nil` on sign-out, with the id your server uses. - [ ] `trackRegistration` on sign-up; `trackStartTrial`, `trackSubscribe` or `trackPurchase` from the purchase flow, with `productId`, `value`, `currency` and `transactionId`. - [ ] `setAppAccountToken` and `notifyPurchase` for every App Store purchase. - [ ] `handleUrl` for every URL the app opens with (scene delegate, app delegate or `.onOpenURL`). - [ ] Existing analytics and attribution SDKs left in place. --- Source: https://kerdly.com/docs/sdks/ios. Index of all docs: https://kerdly.com/llms.txt # Android SDK `com.kerdly:kerdly-sdk` measures installs, users, events and purchases in a native Android app and sends them to your Kerdly project. Kerdly matches each install to the ad that brought it, then to the revenue Google Play reports. Kotlin or Java, open source: [github.com/Kerdly/kerdly-sdk](https://github.com/Kerdly/kerdly-sdk/tree/main/android). Building with Expo or React Native? Use the [Expo SDK](https://kerdly.com/docs/sdks/expo.md) instead: it carries this same Android code. ## Requirements - Android 7.0 (API 24) or newer. - The app's Android app in your Kerdly project. The product form at sign-up makes it when you tick **Android app**; with its package name, purchases and installs line up with Google Play. ## Before you start Open the Android app's **Settings → SDK** in the dashboard. Its **app key** (`pk_live_…`) is already made and shown in the code to paste. App keys are public; they ship inside your app. Use a `pk_test_…` key for test builds, so their traffic stays out of your reports. Never put a server key (`sk_…`) in the app; the SDK refuses it. Each app key belongs to one application id. The SDK sends it with every request, and Kerdly refuses a key used by another app. A build with an `applicationIdSuffix` (for example `.debug`) needs its own key. ## Install The SDK is on Maven Central: ```kotlin // app/build.gradle.kts dependencies { implementation("com.kerdly:kerdly-sdk:0.1.0") } ``` Until 1.0 a minor version may change the API, so update minor versions deliberately. ## Configure Call `configure` once, in `Application.onCreate`. It returns at once; the work happens on the SDK's own thread. ```kotlin class TallybirdApp : Application() { override fun onCreate() { super.onCreate() Kerdly.configure( this, KerdlyOptions( key = "pk_live_…", // Tallybird Android's app key metaAppId = "1234567890", // optional: your Facebook app id ), ) } } ``` | Option | Default | | |---|---|---| | `key` | required | The app's public key: `pk_live_…`, or `pk_test_…` for test builds. | | `endpoint` | `https://app.kerdly.com/api` | Change it only if Kerdly support asks you to. | | `environment` | `AUTO` | `PRODUCTION`, `SANDBOX` or `DEVELOPMENT`. `AUTO` is `DEVELOPMENT` for a debuggable build. | | `collectAdvertisingId` | `true` | Read the Google advertising id when allowed. | | `metaAppId` | none | Your Facebook app id. Turns on Meta install attribution. | | `logLevel` | `WARN` | `NONE`, `ERROR`, `WARN`, `INFO` or `DEBUG`. | Every method is safe from any thread and never throws. Calls made before `configure` run right after it. Java callers get overloads. ## Users and consent After sign-in, set your own user id; it is attached to every later event. Clear it on sign-out. Use the same id your server and RevenueCat use. ```kotlin Kerdly.setUserId(user.id) // after sign-in Kerdly.setUserId(null) // on sign-out Kerdly.setConsent(analytics = true, ads = true) // reflect your consent screen ``` - `analytics = false` stops your custom and standard events; installs and opens are still counted. - `ads = false` stops reading the advertising id and other ad-measurement signals. ## Standard events Send these at the moments ad networks optimize on. Every argument is optional. ```kotlin Kerdly.trackRegistration(method = "google") Kerdly.trackStartTrial("tallybird_pro_weekly", value = 0.0, currency = "USD", transactionId = orderId) Kerdly.trackSubscribe("tallybird_pro_weekly", value = 7.99, currency = "USD", transactionId = orderId) Kerdly.trackPurchase("streak_freeze_5", value = 4.99, currency = "EUR", quantity = 1, transactionId = orderId) ``` - `value` is what the user paid, in `currency` (`0.0` for a free trial). - `currency` is a three-letter ISO 4217 code. A `value` without a valid currency is dropped. - `quantity` is a whole number of 1 or more. - `properties` adds your own fields under the custom-event rules below. These events tell the ad networks early. The revenue in your reports comes from Google Play itself, so renewals and refunds need nothing from the app (see [Client events, server events and deduplication](https://kerdly.com/docs/guides/events-and-dedupe.md)). ## Custom events ```kotlin Kerdly.track("quiz_completed", mapOf("score" to 42, "level" to "hard")) ``` - Names and property keys: lowercase letters, digits and `_`, starting with a letter, at most 40 characters. - At most 25 properties. Values are strings (up to 256 characters), numbers or booleans. - An invalid name drops the event; an invalid property is dropped on its own. With `logLevel = KerdlyLogLevel.DEBUG` logcat says why. ## Link purchases to the install Renewals and refunds come from Google Play. To credit them to the right campaign, link each purchase to the install: 1. Tell the SDK the `obfuscatedAccountId` your purchases carry (with Superwall, the user's alias). 2. After each completed purchase, pass it to `notifyPurchase`. ```kotlin Kerdly.setAppAccountToken(accountId) // in your billing client's or paywall's purchase callback Kerdly.notifyPurchase( KerdlyPurchase( purchaseToken = purchase.purchaseToken, orderId = purchase.orderId, products = purchase.products, purchaseTime = purchase.purchaseTime, obfuscatedAccountId = purchase.accountIdentifiers?.obfuscatedAccountId, ), ) ``` Each purchase token is linked once; calling it again is harmless. For the whole store setup (Play Console access, real-time notifications), see [Sell in a store app](https://kerdly.com/docs/guides/store-app.md). If your app also sends conversions to Meta or TikTok itself, record each send with the event id the network receives: ```kotlin Kerdly.recordNetworkSend(KerdlyNetworkSend("meta", "StartTrial", eventId, 0.0, "USD")) ``` Ids from other SDKs can be attached with `Kerdly.setPartnerIds(mapOf("superwall_alias" to alias))`. ## Deep links Forward every URL your app is opened with. The SDK records the open and returns the Kerdly parameters it found; your app keeps its own navigation. Custom schemes and App Links both work, including [Kerdly links](https://kerdly.com/docs/guides/web-to-app.md). ```kotlin override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) intent?.dataString?.let { Kerdly.handleUrl(it) } } override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) intent.dataString?.let { Kerdly.handleUrl(it) } } ``` `handleUrl` returns a `KerdlyDeepLink` (`url`, `cpp`, `ppid`, `clickId`, `visitId`, `campaignIds`) or null. ## Attribution ```kotlin Kerdly.onAttribution { attribution -> // on the main thread: now if known, and again if it changes Log.d("App", "${attribution.network} ${attribution.campaign}") } val current = Kerdly.attribution // null until known val installId = Kerdly.installId // give it to your backend to tie accounts to installs ``` `Kerdly.flush()` sends queued events now. ## Permissions and manifest The library adds to your merged manifest: - `android.permission.INTERNET`; - `com.google.android.gms.permission.AD_ID`; - `` for the Facebook, Instagram and Facebook Lite apps, used for Meta install attribution on Android 11 and newer. Apps for children or in the Families program should remove the advertising id permission and turn its collection off: ```xml ``` ```kotlin KerdlyOptions(key = "pk_live_…", collectAdvertisingId = false) ``` The SDK's data is excluded from Auto Backup, so no backup rules are needed. ProGuard and R8 rules come with the library. ## Data and privacy What the SDK sends, for your Google Play data safety form: | Data | When | |---|---| | An install id generated by the SDK | always | | Device model, OS version, language, time zone, app version, installer | always | | Google Play and Meta install referrers | once per install | | App events you track | with `analytics` consent | | Purchase identifiers | when you call `notifyPurchase` | | Google advertising id | with `ads` consent and `collectAdvertisingId`, unless the user limited ad tracking | | Public IPv6 address | with `ads` consent | | The user id you set | when you call `setUserId` | | The Google advertising id and install referrer, sent to TikTok to ask which ad led to the install | only with deferred deep links on in your Kerdly project, and `ads` consent | The SDK never collects names, email addresses, phone numbers or contacts, and never reads location services (GPS). ## Check it's working 1. Set `logLevel = KerdlyLogLevel.DEBUG` and run the app on a device or emulator. 2. Filter logcat for `Kerdly`: the SDK logs what it sends and any error Kerdly answers with. 3. In the dashboard, the Android app's **Onboarding** page shows the SDK step with the time of the last event. Events arrive within a minute; `Kerdly.flush()` sends at once. ## Troubleshooting - Kerdly answers `bundle_mismatch`: the key belongs to another Kerdly app, or the application id (with its suffix) doesn't match this app's. - Kerdly answers `bad_key` or `key_revoked`: the key was mistyped or revoked; create a new one under **Settings → SDK**. - Questions or problems: [open an issue](https://github.com/Kerdly/kerdly-sdk/issues) or contact Kerdly support. Never post your keys. ## Agent checklist - [ ] `com.kerdly:kerdly-sdk:0.1.0` in the app module's dependencies. - [ ] `Kerdly.configure` once in `Application.onCreate`, with the Android app's `pk_live_` key (never an `sk_` key), and `metaAppId` if the app runs Meta ads. - [ ] `setUserId` after sign-in and `null` on sign-out, with the id your server uses. - [ ] `trackRegistration` on sign-up; `trackStartTrial`, `trackSubscribe` or `trackPurchase` from the purchase flow, with `productId`, `value`, `currency` and `transactionId`. - [ ] `setAppAccountToken` and `notifyPurchase` for every Google Play purchase. - [ ] `handleUrl` in `onCreate` and `onNewIntent` of the activity that receives links. - [ ] Existing analytics and attribution SDKs left in place. --- Source: https://kerdly.com/docs/sdks/android. Index of all docs: https://kerdly.com/llms.txt