Stripe Subscriptions

Track recurring revenue and subscription lifecycle events. attribu.tech attributes every renewal, upgrade, and cancellation back to the original traffic source.

← Revenue attribution

Make sure you've connected Stripe in your attribu.tech dashboard first. You need a restricted API key linked before payments can be attributed.

Passing metadata

When using Stripe Checkout for subscriptions, pass the attribu.tech cookies as metadata the same way you would for one-time payments. The only difference is mode: "subscription":

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

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

export async function POST(req: Request) {
  const cookieStore = await cookies();

  const session = await stripe.checkout.sessions.create({
    mode: "subscription",
    line_items: [{ price: "price_monthly_xxx", quantity: 1 }],
    success_url: "https://yourdomain.com/success?session_id={CHECKOUT_SESSION_ID}",
    cancel_url: "https://yourdomain.com/pricing",
    metadata: {
      attribu_visitor_id: cookieStore.get("attribu_visitor_id")?.value || "",
      attribu_session_id: cookieStore.get("attribu_session_id")?.value || "",
    },
  });

  return Response.json({ url: session.url });
}
The metadata on the initial checkout session links the subscriber to their traffic source. All future subscription events (renewals, upgrades, cancellations) are automatically attributed to that same source.

Automatically tracked events

attribu.tech listens to Stripe subscription webhooks and records the following events as goals in your dashboard:

GoalDescription
paymentEvery successful charge (initial and recurring)
subscription_startedNew subscription created
subscription_renewedRecurring payment succeeded
subscription_upgradedCustomer moved to a higher-priced plan
subscription_downgradedCustomer moved to a lower-priced plan
subscription_cancel_scheduledCustomer scheduled cancellation at period end
subscription_endedSubscription fully canceled or expired

These goals appear automatically in your dashboard once subscription events start flowing. You can use them in funnels, alerts, and filters like any other goal.

What you'll see

With subscriptions tracked, your attribu.tech dashboard shows:

  • MRR by source -- which traffic channels generate the most recurring revenue
  • Subscriber lifecycle -- upgrades, downgrades, and churn by source
  • LTV -- total revenue per subscriber, attributed to first-touch source
Copied