Amplitude
Overview
The server-side connector forwards subscription lifecycle events from BillDog’s backend into your Amplitude project through Amplitude’s HTTP API. Each event’s user_id is your app user ID (the BillDog customer ID when there is none), and short IDs such as 42 are accepted. Purchases and renewals put their USD amount in Amplitude’s revenue field (revenueType purchase or renewal), and a refund sends the same amount as negative revenue (revenueType refund). The price in the customer’s own currency is in the price_local and currency event properties. The customer’s email, name, country, plan and attribution fields go in user_properties.
For those events to join the behavioural history already in Amplitude, call setUserId(appUserId) in your Amplitude SDK with the same app user ID you give BillDog.
1. Connect your Amplitude project
- In Amplitude, copy your project’s API key from project settings.
- In BillDog, go to Dashboard → Integrations and choose Amplitude.
- Enter the API key. That is the only credential BillDog needs.
- If your Amplitude project is in the EU data center, set Data Residency to European Union so events go to
api.eu.amplitude.com. Events sent to the wrong region land in a different project. - Click Save Integration.
Once connected, BillDog forwards:
| Event | Fires when |
|---|---|
| subscription_created | A new subscription starts, including trials |
| subscription_cancelled | Auto-renew is turned off (the customer keeps access until the period ends) |
| subscription_uncancelled | Auto-renew is turned back on |
| subscription_expired | The subscription ends and access stops |
| purchase_completed | A one-time purchase completes or a subscription renews |
| purchase_refunded | A 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.
Storing the Amplitude user ID (optional)
The SDK also has a setAmplitudeUserID setter. It stores a value on the BillDog customer under the attribution key amplitudeUserId, 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 user_id.
// iOS — setter is async throws
Task {
try? await BillDog.shared.setAmplitudeUserID(amplitudeUserId)
}// Android — suspend function returning Result<Unit>
scope.launch {
BillDog.getInstance().setAmplitudeUserID(amplitudeUserId)
}// React Native — fire-and-forget, returns void
BillDog.setAmplitudeUserID(amplitudeUserId);Call it after customer info has loaded: with no current customer the setter fails (iOS throws, Android returns a failed Result).
Consent gating
The setter is gated by the SDK’s consent flag. If your app requires consent and it hasn’t been given, the setter fails (iOS throws; Android returns a failed Result). Nothing is queued and nothing leaves the device; call it again after setConsentGiven(true). The server-side connector is unaffected by device consent because it sends from BillDog’s backend.
Related
Was this page helpful?
Or rate this page: