Client SDKs

RevenueCat Integration

Connect Audiencelab and RevenueCat so subscription purchases attribute to the Audiencelab install

Use this guide when your Android app uses both the Audiencelab SDK and RevenueCat. Audiencelab joins RevenueCat purchase and renewal webhooks to the original install using a shared device id.

Requires Audiencelab Android SDK 1.1.11 or later.

What you set up

  1. Audiencelab SDK initialized in the app
  2. RevenueCat Purchases SDK configured in the app
  3. getRevenueCatAttributes() copied onto the RevenueCat subscriber before the first paywall
  4. RevenueCat connected in the Audiencelab dashboard (webhook URL and AL secret)
  5. That webhook configured in the RevenueCat project with the AL secret from the connect dialog

You do not need to call sendPurchaseEvent for RevenueCat-managed subscriptions. Renewals can attribute even when the app is closed.

1. Install and initialize

Install Audiencelab as usual (Installation) and initialize before any RevenueCat paywall:

import app.geeklab.audiencelab.sdk.AudienceLabOptions
import app.geeklab.audiencelab.sdk.AudienceLabSDK
import com.revenuecat.purchases.Purchases
import com.revenuecat.purchases.PurchasesConfiguration

AudienceLabSDK.initialize(
    context = applicationContext,
    apiKey = BuildConfig.AUDIENCELAB_API_KEY,
    options = AudienceLabOptions(
        isDevelopmentMode = BuildConfig.DEBUG,
        isDebugEnabled = BuildConfig.DEBUG,
        autoResolveGooglePlayIds = true
    )
)

Purchases.configure(
    PurchasesConfiguration.Builder(this, "YOUR_REVENUECAT_API_KEY").build()
)

Open the app at least once with a valid creative token path so Audiencelab can store device identity for later joins.

2. Pass Audiencelab identity into RevenueCat

After both SDKs are ready, and before the first paywall, copy Audiencelab's device id onto the RevenueCat subscriber. Safe to call on every cold start:

Purchases.sharedInstance.setAttributes(
    AudienceLabSDK.getRevenueCatAttributes()
)

getRevenueCatAttributes() returns a string map with:

KeyValue
audienceLabIdGoogle Advertising ID (ga), else App Set ID (asid), else Android ID (aid). All-zero GAID is treated as missing.

Empty values are omitted. There is no RevenueCat SDK dependency inside Audiencelab; your app calls RevenueCat's setAttributes with the map Audiencelab returns.

Custom RevenueCat attribute keys must not start with $. audienceLabId is intentional.

3. Connect RevenueCat in the Audiencelab dashboard

In Audiencelab, open the app's integrations / data sources flow and connect RevenueCat:

  1. Enter your RevenueCat project id
  2. Save
  3. Copy the webhook URL and the AL secret from the connect dialog

The webhook URL looks like https://analytics.geeklab.app/webhooks/revenuecat. The AL secret is the same value as the app API key (returned as al_secret).

4. Add the webhook in RevenueCat

In the RevenueCat dashboard for that project:

  1. Open Integrations → Webhooks
  2. Add a webhook using the Audiencelab webhook URL
  3. Paste the AL secret from the Audiencelab connect dialog into RevenueCat's Authorization header value field. Prefer Bearer <al_secret>; the raw AL secret is also accepted. Do not enable HMAC webhook signing.
  4. Set the environment to Production only
  5. Enable at least:
    • INITIAL_PURCHASE
    • RENEWAL
    • NON_RENEWING_PURCHASE

Other event types can stay enabled; Audiencelab acknowledges them and skips ingest for v1.

5. Verify

  1. Cold-open the app so getRevenueCatAttributes() runs after both SDKs initialize
  2. Complete a Production store purchase or trial conversion through a Production RevenueCat webhook (converting with the app closed is the strongest test)
  3. Confirm the purchase appears in Audiencelab attributed to the install creative

Notes

  • Audiencelab ignores RevenueCat Sandbox environment events. Configure the webhook for Production only.
  • Device-local total_purchase_value only updates from sendPurchaseEvent. RevenueCat webhook purchases are recorded server-side and do not bump on-device cumulative totals.
  • Do not rely on RevenueCat $gpsAdId alone for the join. Always call getRevenueCatAttributes() so audienceLabId is present on later webhooks.
  • If Google Play ID lookup can stall in restricted networks, use autoResolveGooglePlayIds = false and supply identity through the documented setters or providers before calling getRevenueCatAttributes().