Sign up

Revenue

Connect Stripe

On this page

Two parts: import payments with a restricted key, then link checkouts to visits. You can import revenue before adding attribution.

Import payments

  1. Open Settings → Integrations → Stripe

    In your MetricRaven site settings.

  2. Create a live restricted key in Stripe

    In your Stripe API keys, create a live restricted key. If Stripe asks how you will use it, choose “Providing this key to a third-party application”, enter MetricRaven and https://metricraven.com, then select “Customize permissions for this key”.

    Set every permission group to None, then grant Read only for the resources in the permissions table.

  3. Paste the key and choose Connect Stripe

    Paste the rk_live_… key. Publishable keys and unrestricted secret keys are not accepted.

  4. Wait for Connected

    The status changes from Importing history to Connected. Large histories import in batches; Last sync and the scanned-payment count show progress.

Stripe's suggested defaults can include Write access. MetricRaven only needs Read.

Required read permissions

ResourceWhy
AccountsRead account information to identify the connection.
Charges and RefundsRead successful payments, refund totals and refund dates.
EventsRead new payments, captures and refunds.
Subscriptions, Coupons, Products and PricesRead live subscription states, recurring prices and ongoing discount details.
CustomersRead stable attribution metadata.
PaymentIntentsRead payment metadata.
Checkout SessionsRead checkout metadata.
Invoices, including Invoice PaymentsRead invoice links, subscription renewal reason and plan information.

Attribute checkout to a visit

  1. Read the visitor ID in the browser

    Pass it to your existing checkout endpoint:

    script.js
    // Read this in the visitor's browser when they start checkout.
    const visitorId = window.analytics?.getVisitorId() ?? null;
    // Send visitorId to your own checkout endpoint alongside its usual request data.
    // Use the authenticated user ID from your backend; do not trust a browser-supplied user ID.
  2. Add metadata when creating the Checkout Session

    Replace the example price, URLs and user ID with your own. For a guest checkout, omit the user ID if you don't have one.

    One-time Stripe Checkout
    // In your existing server-side checkout handler.
    // stripe is your initialized Stripe client; visitorId came from your browser.
    const attribution = {
      metricraven_visitor_id: visitorId || "",
      metricraven_user_id: authenticatedUser.id,
      metricraven_plan: "pro",
    };
    const session = await stripe.checkout.sessions.create({
      mode: "payment",
      line_items: [{ price: "YOUR_STRIPE_PRICE_ID", quantity: 1 }],
      success_url: "https://example.com/success",
      cancel_url: "https://example.com/pricing",
      metadata: attribution,
      payment_intent_data: { metadata: attribution },
    });
    Recurring Stripe Checkout
    // Subscription checkout uses subscription_data instead of payment_intent_data.
    const attribution = {
      metricraven_visitor_id: visitorId || "",
      metricraven_user_id: authenticatedUser.id,
      metricraven_plan: "pro_monthly",
    };
    const session = await stripe.checkout.sessions.create({
      mode: "subscription",
      line_items: [{ price: "YOUR_RECURRING_STRIPE_PRICE_ID", quantity: 1 }],
      success_url: "https://example.com/success",
      cancel_url: "https://example.com/pricing",
      metadata: attribution,
      subscription_data: { metadata: attribution },
    });
  3. Identify signed-in users

    Call the Identify API when a visitor signs in, so later payments stay linked to that user.

Verify it works

After a successful live payment and sync, find it in Revenue using the payment's currency. With attribution metadata or a linked user, Traffic can credit it to a source.

Subscriptions and MRR

Revenue → Stripe subscriptions shows the current live state, separate from the selected payment dates. Estimated MRR includes active and past-due recurring prices after ongoing discounts.

Details

  • MetricRaven reads Stripe data; it does not create charges or issue refunds. Your key is stored encrypted, used only by the server and never returned in dashboard reports or shared links.
  • Payments and refunds sync automatically after the initial import. Use Sync now to request another check. If a key is revoked or loses permissions, the card shows an error and retries later.
  • The examples use your existing server-side Stripe client. Checkout Session metadata and PaymentIntent metadata are separate; subscription checkout uses subscription_data.
  • Estimated MRR annualizes recurring prices using 52 weeks or 365 days and divides by 12. Trials, one-time coupons, taxes and invoice rounding are excluded. Unsupported pricing or incomplete discounts show as unavailable. Status counts include free plans.
  • Subscription events sync automatically, with an hourly paginated reconciliation to repair missed changes.
  • Choose the revenue currency with the toolbar's globe button (timezone and currency). Currencies are reported separately; MetricRaven does not perform FX conversion.
  • Stripe revenue uses captured amounts before Stripe fees, with recorded refunds deducted.
  • Historical revenue can be imported, but visits before the tracker was installed cannot be reconstructed.
  • Stripe events are available for about thirty days, so a longer disconnection may require a historical re-import.