Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    Braze

    Overview

    BillDog sends subscription lifecycle events (starts, renewals, cancellations, refunds, failed payments and trial reminders) to Braze from its servers, using Braze’s /users/track REST endpoint. BillDog sends them from its own store and payment processing, so they arrive whether or not the app is open.

    Each event goes to the Braze user whose external ID is your BillDog app user ID. That is the only way BillDog matches a Braze user today.

    Part 1: Use the same user ID in Braze

    Call Braze’s changeUser with the same app user ID you give BillDog (the ID you pass to BillDog’s identify). If the two IDs differ, Braze files the events under a user your campaigns never see.

    // iOS (BrazeKit)
    braze.changeUser(userId: appUserId)
    
    // Android
    Braze.getInstance(context).changeUser(appUserId)
    
    // React Native (@braze/react-native-sdk)
    Braze.changeUser(appUserId);

    Events with no app user ID are not sent. If BillDog can’t resolve an app user ID for the customer, the Braze delivery is skipped and shows as skipped with no_app_user_id in the integration’s Recent Activity.

    Part 2: Connect Braze in the dashboard

    Go to Dashboard → Integrations → Braze (/dashboard/integrations) and enter:

    • REST API Key: a key from your Braze dashboard (Settings → API Keys) with the users.track permission. BillDog stores it encrypted.
    • REST Endpoint: your cluster’s REST endpoint, for example https://rest.iad-01.braze.com or https://rest.fra-01.braze.eu. Only https://rest.<cluster>.braze.com and .braze.eu addresses are accepted.

    Then choose which events to forward under Events to Forward. If you select none, every event is forwarded.

    What Braze receives

    Every event is sent as a Braze custom event named exactly as below. Build your campaign triggers and segments on these names.

    Braze custom eventFires whenAlso logged as a Braze purchase
    subscription_createdA subscription or free trial starts (App Store, Google Play, Stripe web checkout, or a purchase you record through the external-purchase API).Yes, when it was paid (not a free trial) and has a product ID
    purchase_completedA subscription renews, or a one-time purchase completes.Yes, when it has a product ID
    subscription_cancelledAuto-renew is turned off. The customer keeps access until the period ends.Never
    subscription_uncancelledAuto-renew is turned back on.Never
    subscription_expiredThe subscription ends and access stops.Never
    purchase_refundedAn App Store or Google Play purchase is refunded.Never
    payment_failedA payment fails: App Store failed-to-renew or grace period, Google Play on hold or grace period, a failed Stripe invoice, or a failed Stripe web checkout payment.Never
    trial_endingOnce per App Store or Google Play trial period, about three days before it ends, or when Stripe reports that a web trial is about to end.Never

    Each lifecycle fact is its own event, so one churn sends one subscription_cancelled. Expirations and refunds used to arrive as subscription_cancelled too. An integration saved before the change keeps the events it had: tick subscription_expired, purchase_refunded and subscription_uncancelled to receive them. Stripe web checkout’s failed payments and trial reminders arrive as payment_failed and trial_ending, the same names as the stores’.

    Event properties

    Each custom event carries whichever of these fields the event has: product_id, transaction_id, store, platform, period_type, is_trial, is_sandbox, plan, entitlement_id. No other fields are sent.

    Purchases

    When a paid purchase or renewal (subscription_created or purchase_completed with a non-zero amount) has a product ID, BillDog also sends a Braze purchase with that product_id, currency: "USD" and price set to the USD amount. Prices are always sent in USD, converted from the customer’s local currency. Cancellations, expirations, refunds and failed payments are never logged as purchases.

    Sandbox traffic

    Sandbox and test-store purchases are forwarded too, with is_sandbox: true in the properties. Filter on that property if you don’t want them in production campaigns.

    Storing the Braze device ID (optional)

    The SDK also has a setBrazeID setter. It stores the Braze device ID on the BillDog customer under the attribution key brazeId, and the value comes back in the customer’s attribution data. The Braze integration above does not use it: events are matched by external ID only. Matching Braze users by device ID is coming soon.

    // iOS (Braze Swift SDK 17+): the async accessor avoids blocking the main thread.
    // On older Braze SDKs, read braze.deviceId instead.
    import BillDogFull
    import BrazeKit
    
    braze.getDeviceId { deviceId in
        guard let deviceId else { return }
        Task { try? await BillDog.shared.setBrazeID(deviceId) }
    }
    // Android: deviceId is blocking, so read it off the main thread
    import io.billdog.core.BillDog
    import com.braze.Braze
    import kotlinx.coroutines.Dispatchers
    import kotlinx.coroutines.withContext
    
    scope.launch {
        val deviceId = withContext(Dispatchers.IO) { Braze.getInstance(context).deviceId }
        BillDog.getInstance().setBrazeID(deviceId)
    }
    // React Native: fire-and-forget, returns void
    import { BillDog } from '@billdog.io/react-native';
    
    // Braze's React Native getDeviceId takes a callback; it doesn't return a promise.
    Braze.getDeviceId((error, deviceId) => {
      if (error || !deviceId) return;
      BillDog.setBrazeID(deviceId);
    });

    The setter is gated by the SDK’s consent flag. If your app requires consent and it hasn’t been given, the call fails (iOS throws; Android returns a failed Result) and nothing is stored or queued. Call it again after you grant consent.

    Related

    Was this page helpful?

    Or rate this page:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.