"The only analytics dashboard I open every day"

Revenue attribution with Stripe

Pass the visitor id from the dataeasy_visitor_id cookie when you create the Checkout Session on your server. For subscriptions, also copy it to subscription_data.metadata so renewals are attributed too.

1. Add the metadata

app/api/checkout/route.ts (Next.js)
import { cookies } from "next/headers";
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

export async function POST() {
  const jar = await cookies();
  const visitorId = jar.get("dataeasy_visitor_id")?.value;
  // dataeasy_session is "<session id>.<timestamp>"
  const sessionId = jar.get("dataeasy_session")?.value?.split(".")[0];

  const metadata = {
    ...(visitorId && { dataeasy_visitor_id: visitorId }),
    ...(sessionId && { dataeasy_session_id: sessionId }),
  };

  const session = await stripe.checkout.sessions.create({
    mode: "subscription",
    line_items: [{ price: "price_123", quantity: 1 }],
    success_url: "https://yourdomain.com/thanks",
    cancel_url: "https://yourdomain.com/pricing",
    metadata,
    subscription_data: { metadata }, // renewals
  });

  return Response.json({ url: session.url });
}

Not on Next.js? Any backend works: read the dataeasy_visitor_id cookie from the incoming request (e.g. req.cookies.dataeasy_visitor_id in Express) and pass it the same way.

2. Connect the webhook

  1. In DataEasy, open Website settings → Revenue and pick Stripe.
  2. Copy the webhook endpoint shown there. It looks like https://dataeasy.app/api/integrations/stripe/webhook/<website id>.
  3. In your Stripe dashboard, create a webhook pointing to that URL and subscribe it to: checkout.session.completed, invoice.paid, charge.refunded.
  4. Paste the webhook signing secret back in DataEasy and save.
Stripe eventRecorded as
checkout.session.completedNew payment (paid sessions only)
invoice.paidRenewal (subscription cycles only; the first invoice is covered by the checkout)
charge.refundedRefund

Stripe Payment Links and the PaymentIntent API work the same way as long as the payment ends up with dataeasy_visitor_id in its metadata (the webhook reads the session, invoice, subscription or charge metadata).

✍️ Something missing? Tell us.

🧭 New to DataEasy? Start with the introduction