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

    Segment

    Overview

    The server-side connector forwards BillDog subscription lifecycle events from BillDog’s backend into your Segment source. Each event is a track call whose userId is your app user ID (the BillDog customer ID when there is none), followed by an identify call with the customer’s traits (email, name, country, attribution fields) when there are any. Purchases and renewals carry their USD amount in revenue with currency USD, and a refund carries the same amount negative. The price in the customer’s own currency is in price_local and local_currency.

    For those events to land on the same Segment profile as your app’s own events, call analytics.identify(appUserId) in your app with the same app user ID you give BillDog.

    1. Connect your Segment source

    Go to Dashboard → Integrations, choose Segment, and paste the Write Key from your Segment source settings. If your Segment workspace is in the EU, set Data Residency to European Union so events go to events.eu1.segmentapis.com instead of api.segment.io. Then click Save Integration.

    Once connected, BillDog forwards these events:

    EventFires when
    subscription_createdA new subscription starts, including trials
    subscription_cancelledAuto-renew is turned off (the customer keeps access until the period ends)
    subscription_uncancelledAuto-renew is turned back on
    subscription_expiredThe subscription ends and access stops
    purchase_completedA one-time purchase completes or a subscription renews
    purchase_refundedA purchase is refunded (sent as negative revenue)

    Untick events under Events to Forward to stop sending them. If you untick every event, BillDog forwards all of them: an empty selection means no filter.

    2. Checking delivery

    The chart icon on the Segment card opens Recent Activity, the last 50 dispatch attempts with their status (success, failed or skipped). After 3 failed deliveries within an hour the integration’s status changes to error, and from then on BillDog stops sending it events. Events that occur while it is in error are dropped and are not replayed later. Fix the cause (usually a rotated write key), then click Retry on the card: it sends a test event, and a successful send sets the integration back to active.

    Storing the Segment anonymous ID (optional)

    The SDK also has a setSegmentAnonymousID setter. It stores Segment’s anonymous ID on the BillDog customer under the attribution key segmentId, and the value comes back in the customer’s attribution data. The connector above does not use it: events are sent with your app user ID as userId.

    // iOS — setter is async throws
    import BillDogFull
    import Segment
    
    Task {
        try? await BillDog.shared.setSegmentAnonymousID(analytics.anonymousId)
    }
    // Android — suspend function returning Result<Unit>
    import io.billdog.core.BillDog
    
    scope.launch {
        BillDog.getInstance().setSegmentAnonymousID(analytics.anonymousId())
    }

    Call it after customer info has loaded: with no current customer the setter fails (iOS throws, Android returns a failed Result). It is also gated by the SDK’s consent flag. If your app requires consent and it hasn’t been given, the call fails the same way and nothing is stored or queued; call it again after setConsentGiven(true). The server-side connector is not affected by device consent, because it sends from BillDog’s backend.

    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.