Payments
Connect Stripe to see revenue in Databuddy, credited to the visit, campaign and user that brought it.
Connect Stripe
Open Website → Revenue and choose Connect Stripe, then approve read access in Stripe. There's no webhook to create.
If you can't connect, use the manual webhook.
Add browser identity to your payments
import { getRevenueMetadata } from "@databuddy/sdk";
// Browser: send this visit's IDs with the checkout request
await fetch("/api/checkout", {
method: "POST",
body: JSON.stringify({ metadata: getRevenueMetadata() }),
});// Server: keep only the visit from the browser, and set who paid yourself
const visit = Object.fromEntries(
Object.entries(body.metadata ?? {}).filter(
([key]) => key === "databuddy_session_id" || key === "databuddy_anonymous_id"
)
);
const metadata = {
...visit,
databuddy_client_id: process.env.DATABUDDY_CLIENT_ID,
databuddy_profile_id: user.id, // leave out for guest checkout
};Databuddy tries the session, then the profile, then the anonymous ID. Each needs a matching browser event on the same website at or before the payment. Session IDs must come from the browser tracker; IDs made on the server, or sent with server-side track(), never match. Prefer session and profile IDs for renewals, since anonymous IDs can stop matching once their privacy salt rotates.
When nothing matches, an earlier verified session for the same Stripe customer can still credit a renewal. Revenue attribution is attributed completed-payment revenue divided by all completed-payment revenue in that currency, with refunds shown separately.
Read recurring revenue
Revenue shows MRR, ARR, ACV and active subscriptions from Stripe with no extra setup. Without Stripe subscriptions, they come from the MRR your accounts send.
MRR movement splits each day's change into new, expansion, contraction and churn. Beside it are net and gross revenue retention, subscription churn and the quick ratio. Biggest changes lists the subscriptions that moved MRR most, each linked to Stripe.
Check it works
Send a Stripe test payment, then open Website → Revenue. If you sent a profile ID, the payment also shows on that user in Website → Users.
Manual webhook setup
Use this only for a Stripe account you don't connect. Open Website → Revenue, choose Use a webhook instead or Add a webhook, then Add webhook URL. Add that URL as an endpoint in the Stripe dashboard with these events:
| Event | Purpose |
|---|---|
invoice.paid | Subscriptions and invoices: links each invoice to its visitor |
invoice_payment.paid | Subscriptions and invoices: records the amount paid |
payment_intent.succeeded | One-time payments: records the amount paid |
Set the endpoint's API version to 2025-03-31.basil or later, which is the first with invoice_payment.paid. Enable both invoice events for subscriptions: one carries the amount, the other your metadata. invoice.payment_succeeded also works in place of invoice.paid.
Paste the endpoint's signing secret (whsec_…) into Revenue settings. Until then, deliveries are refused; Stripe retries them for up to 3 days, so they're recorded once it's saved.
Related
How is this guide?