Attribution tells the spec where each install came from and what it paid, so a release is judged on the organic installs and revenue it brought. Setting it up takes four steps: a server, the SDK, your purchases, and two lines in the spec.
Three pieces
01
The SDK
In your app. Records the install, where it came from and the screens, and who the user is.
02
The server
Appeeky Analytics: receives installs and purchases and matches them. Yours on Cloudflare, or Appeeky's.
03
The spec
Reads the server: verify, data pull and experiment links.
Purchases reach the server from RevenueCat or Superwall, not from the app. The SDK only says which user an install belongs to, so the server can match the purchase to the install and its source.
Pick the server
Hosted by Appeeky
via: hosted
In Appeeky, open the app's Attribution tab and turn it on. Setup shows the app's publishable key (apk_…) and the RevenueCat webhook to add. Nothing to run.
Self-hosted on Cloudflare
via: self
Appeeky Analytics on Workers and D1, in your own account. The free Workers plan is enough to start, and the data never leaves your account.
To self-host, you need Node 20 and a Cloudflare account:
$ git clone https://github.com/appeeky/appeeky-analytics && cd appeeky-analytics$ npm install && cd apps/worker$ npx wrangler login$ npx wrangler d1 create appeeky-analytics
Copy the database_id it prints into apps/worker/wrangler.toml. Then set two secrets, long random values, and deploy:
$ openssl rand -hex 32 | npx wrangler secret put ADMIN_TOKEN$ openssl rand -hex 32 | npx wrangler secret put REVENUECAT_WEBHOOK_SECRET$ npm run deploy
The deploy prints your server's URL. Create one app per platform; each answer has the app's id and its publishableKey:
$ curl -X POST https://analytics.sleepsounds.workers.dev/v1/apps \-H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \-d '{"name":"Sleep Sounds","platform":"apple","storeAppId":"1234567890"}'
Add the SDK
For React Native and Expo:
$ npx expo install @appeeky/analytics-expo @react-native-async-storage/async-storage expo-application expo-device
Add "@appeeky/analytics-expo" to the plugins in app.json and make a new development build: the plugin brings the native module that reads the Apple Search Ads token and the Google Play install referrer. Then, once, when the app starts:
import Appeeky from "@appeeky/analytics-expo";import Purchases from "react-native-purchases";Appeeky.init({ key: "apk_..." });// Self-hosted: Appeeky.init({ key: "apk_...", endpoint: "https://analytics.example.com/v1/ingest" });// Link the install to the RevenueCat customer, so purchases find their source.Appeeky.identify(await Purchases.getAppUserID());
Call identify again after Purchases.logIn(), and with null on logout. The other SDKs work the same way:
Appeeky.configure(key: "apk_...")Appeeky.identify(Purchases.shared.appUserID)
Appeeky.configure(this, "apk_...")Appeeky.identify(Purchases.sharedInstance.appUserID)
Appeeky.init(key: 'apk_...');Appeeky.identify(await Purchases.appUserID);
No IDFA and no tracking prompt: the install id is a random id kept in the app. Events are queued on the device and sent in batches.
Connect purchases
In RevenueCat, open Integrations, then Webhooks, and add one. Hosted: use the URL and header from the Attribution tab. Self-hosted:
- URL:
https://<your server>/v1/webhooks/revenuecat - Authorization header: your
REVENUECAT_WEBHOOK_SECRET - Environment: production
With Superwall, add its webhook the same way and pass the user id you give Superwall.shared.identify to Appeeky.identify.
Check the first install
Run the app. Within about ten seconds the server has the install, its source and the screens. Self-hosted, open your server's URL and sign in with the admin token, or ask it directly:
$ curl -H "Authorization: Bearer $ADMIN_TOKEN" https://analytics.sleepsounds.workers.dev/v1/apps/app_ios123/users?range=today{"users":[{"source":"organic","platform":"ios","country":"US","sessions":1,"appUserId":"$RCAnonymousID:8f2…","status":"free"}]}
A simulator or a development build always shows organic: Apple Search Ads attribution only comes from a real device that installed through an ad. Sandbox purchases are ignored on purpose, so test revenue never mixes with real revenue.
Tell the spec
attribution init does it for you: it finds or creates the app for each store in the spec, writes attribution: and prints the keys and the webhook to add. Hosted, without --self.
$ npx @appeeky/spec attribution init --self https://analytics.sleepsounds.workers.devFound App Store app app_ios123 · key apk_pub_mSp…Created Google Play app app_and456 · key apk_pub_qcZ…Wrote attribution: to appeeky.spec.yaml.
Or by hand:
attribution:via: selfurl: https://analytics.sleepsounds.workers.devapp:app-store: app_ios123 # one app per platformgoogle-play: app_and456
Self-hosted, set ATTRIBUTION_TOKEN to the admin token, outside the repo like your store keys. Hosted, it is via: hosted with your App Store ID or package name as the app, and your APPEEKY_API_KEY. Then:
$ npx @appeeky/spec data pull✓ .appeeky/data/attribution-sources-app-store.csv✓ .appeeky/data/attribution-campaigns-app-store.csv✓ .appeeky/data/attribution-sources-google-play.csvIn .appeeky/data/ (gitignored).
From now on verify compares organic installs, their revenue and the share that paid around each push, each store with its own app. When no target rank moved, those numbers decide the verdict.
What it can and cannot see
Installs from before the SDK
The server starts counting at the first launch of a build with the SDK in it.
Search Ads keywords as ids
Apple reports the keyword id, not the words. The words are in your Search Ads account.
Smart link installs on iOS
The App Store passes nothing from a click to a new install, and there is no device fingerprinting. Link installs are Google Play installs; on iOS, measure link clicks.
Sandbox and test purchases
Ignored, so they never count as revenue.
Next: measure installs with attribution, around every push and for every experiment.