# Connect Stripe > Send your Stripe payments to Supametrics with a webhook, pass the visitor ID so each payment is credited to the visit that brought the buyer, and test it. Source: https://supametrics.io/docs/connect-stripe Supametrics records **paid Stripe payments**: one-time payments made with Checkout, Payment Links or the Payment Element, and **subscription invoices** (the first one as new revenue, later ones as renewals). It credits each one to the visit that brought the buyer. Refunds come off revenue on the day they're issued. Stripe is the only payment provider supported today. The other providers in the **Payment provider** list (Polar, LemonSqueezy, Paddle, DodoPayments, Easytool, Other) are marked **Soon** and can't be picked yet. ## Where to set it up - **Site settings › Revenue** (`/settings/revenue`), in the **Stripe** section. It walks through five steps and ticks each one off, with the connection status as a badge next to the title. - The **Revenue** screen (`/revenue`) has the same steps (numbered 1 to 4, without the provider pick) next to your revenue figures. See [Revenue and attribution](https://supametrics.io/docs/revenue). Set it up in **Stripe test mode** first, check it end to end, then repeat for live mode. ### Who can connect Stripe Owners and members can paste the signing secret, disconnect Stripe, clear test payments and change every revenue setting. Viewers can read the setup and the connection status, but can't change anything: they see **You have view-only access, so the owner or a member connects Stripe.** See [Team members and roles](https://supametrics.io/docs/team-and-roles). ## 1. Pass the visitor ID into the payment This is what links a payment to a visit. Without it the payment still counts towards revenue, but as **Unattributed**. The step is ticked once some of your payments carry a visitor ID. ### Checkout Sessions (your server creates the session) Read the visitor ID in the browser and send it with your checkout request: ```js const visitorId = window.analyticsx?.('visitorId'); // null if the script is blocked or consent is missing await fetch('/api/checkout', { method: 'POST', body: JSON.stringify({ priceId, visitorId }) }); ``` Put it in the session's metadata as `ax_visitor_id`: ```js const session = await stripe.checkout.sessions.create({ mode: 'payment', line_items: [{ price: priceId, quantity: 1 }], metadata: { ax_visitor_id: visitorId ?? '' }, success_url: 'https://example.com/thank-you', }); ``` ### Payment Links Add the visitor ID as `client_reference_id` on the link when the page loads: ```js const a = document.querySelector('a[href^="https://buy.stripe.com/"]'); const visitorId = window.analyticsx?.('visitorId'); if (a && visitorId) a.href += (a.href.includes('?') ? '&' : '?') + 'client_reference_id=' + visitorId; ``` `metadata.ax_visitor_id` is used first; `client_reference_id` is the fallback. ### Subscriptions Pass the visitor ID the same way: in the metadata of a `mode: 'subscription'` Checkout Session, as `client_reference_id` on a Payment Link, or in the subscription's own metadata when your server creates it: ```js const subscription = await stripe.subscriptions.create({ customer: customerId, items: [{ price: 'price_monthly' }], metadata: { ax_visitor_id: visitorId || 'none' }, }); ``` Every invoice of the subscription is credited to the source that won the customer, including renewals months later. If a subscription carries no visitor ID, Supametrics uses one from another subscription of the same Stripe customer, when it has one. ### Payment Element (or any PaymentIntent you create yourself) Send the visitor ID to your server as above, and put it in the PaymentIntent's metadata. Always set it, using `'none'` when the script was blocked: ```js const paymentIntent = await stripe.paymentIntents.create({ amount: 4900, currency: 'usd', metadata: { ax_visitor_id: visitorId || 'none' }, }); ``` PaymentIntents **without** `ax_visitor_id` are ignored. Stripe also creates PaymentIntents for subscriptions and invoices, and since API version 2025-03-31 a PaymentIntent no longer says where it came from, so the tag is how Supametrics knows it's a one-time payment. `'none'` counts the payment as **Unattributed**. Checkout payments have a PaymentIntent too. If you use both, each sale is still recorded once. > **Note:** Sites set up before Supametrics' rename may send `df_visitor_id`. It still works. ## 2. Add the webhook endpoint in Stripe In the Stripe Dashboard (test mode on), go to **Developers › Webhooks › Add endpoint**: - **Endpoint URL**: copy it from Supametrics with **Copy URL**. It looks like `https://app.supametrics.io/api/webhooks/stripe/YOUR_SITE_KEY`, and is different for every website. - **Events**: - one-time payments: `checkout.session.completed` and `checkout.session.async_payment_succeeded`, plus `payment_intent.succeeded` if you use the Payment Element; - subscriptions: `invoice.paid`, `customer.subscription.created`, `customer.subscription.updated` and `customer.subscription.deleted`. Without them, subscription payments, renewals, MRR, the **Subscription metrics** panel and the **Product filter** in **Site settings › Revenue** get no data. - refunds: `charge.refunded`, `refund.created` and `refund.updated`. Each refund comes off revenue on the day it was issued, credited to the same source as the payment (**Site settings › Revenue** › **Subtract refunds from revenue** turns this off). Supametrics also understands `invoice.payment_succeeded`, `customer.subscription.paused`, `customer.subscription.resumed`, `customer.subscription.trial_will_end`, `refund.failed` and `charge.refund.updated` if you send them, but they aren't needed. Other events are accepted and ignored. ## 3. Paste the signing secret Open the endpoint in Stripe, reveal its **Signing secret** (starts with `whsec_`) and paste it into Supametrics, then click **Connect** (**Save** on the Revenue screen). Anything that doesn't look like a signing secret is refused with **A Stripe signing secret starts with whsec_**. The secret is stored for this website only and shown masked afterwards (`whsec_••••` and its last four characters). Viewers never see it. Every webhook's signature is checked against this secret. A webhook with a wrong or missing signature is rejected and **never** creates revenue; the status then shows **Signature failing**, with the time of the **Last rejected** webhook. ## 4. Test it Either: - buy something on your site in test mode with the card `4242 4242 4242 4242` (any future date, any CVC), or - run `stripe trigger checkout.session.completed` with the [Stripe CLI](https://docs.stripe.com/stripe-cli). This payment has no visitor ID, so it appears as Unattributed. The screen checks for the first webhook every few seconds by itself. Any verified event counts, including Stripe's **Send test event**. The status then shows **Connected** with the time and type of the **Last verified webhook**, and on the Revenue screen the payment appears under **Latest payments** with its attribution and source. ### Connection status | Status | Meaning | |---|---| | **Not connected** | No signing secret saved yet. | | **Waiting for the first webhook** | A secret is saved, but no verified webhook has arrived. | | **Connected** | Webhooks are arriving and their signatures match. | | **Signature failing** | The latest webhook was rejected: its signature didn't match the saved secret. Copy the signing secret again from the same endpoint in Stripe. | ## Test mode and live mode Test-mode payments are labelled **Test** and count like real ones until the website's first live payment, so you can see the whole flow on the dashboard. From the first live payment on they are left out of every number automatically (subscription figures included); they stay listed. **Clear test payments** deletes the website's test-mode payments for good. Live payments are not affected. Owners and members see the button wherever the test payments are mentioned. ## 5. Go live Stripe gives live mode its own endpoints and secrets. Repeat steps 2 and 3 with test mode off. A website holds one signing secret at a time: click **Disconnect** (on the Revenue screen, **Replace or disconnect**), then paste the **live** signing secret. After the switch, test-mode webhooks are rejected. Disconnecting stops new payments from being recorded. Past revenue stays on your dashboard. ## Currency Revenue is reported in one currency per website, set under **Site settings › Revenue** › **Currency** (chosen when you added the website). Payments in other currencies are stored but not counted, and the Revenue screen says how many there are. Nothing is converted between currencies. Changing the currency asks for confirmation. Afterwards only payments made in the new currency count, including past ones; payments in the old currency stay stored but drop out of your revenue. ## Other revenue settings **Site settings › Revenue** also has: - **Include renewal revenue in KPIs** (on by default): counts subscription renewals in Revenue, Revenue/visitor and Conversion. - **Subtract refunds from revenue** (on by default): totals read New + Renewal − Refunds. - **Product filter**: choose which Stripe products count toward revenue. Products appear once a payment for them arrives. Unticked products don't count anywhere, the Subscription metrics panel included; payments that name no product (most one-time Checkout payments) always count. Click **Save** to apply. How these change the numbers is explained in [Revenue and attribution](https://supametrics.io/docs/revenue). ## How payments are credited - A payment goes to the visitor's **most recent visit that came from somewhere** (search, social, AI, email, a tagged link) **within the 30 days before paying**. Someone who clicked your tweet and came back directly a week later to pay is credited to the tweet. - No such visit in 30 days: credited to **Direct**. - No visitor ID, or one Supametrics never saw: **Unattributed**. - The source, campaign and landing page are saved on the payment when it arrives and never change later. - Stripe retries the same webhook if it doesn't get an answer; each payment is recorded once. More in [Revenue and attribution](https://supametrics.io/docs/revenue). ## Troubleshooting - **Signature failing**: the secret doesn't belong to this endpoint, or you switched Stripe between test and live mode. Copy the secret again from the endpoint that sends the events. - **Payments arrive but are all Unattributed**: the visitor ID isn't reaching Stripe. Check step 1, and that `window.analyticsx?.('visitorId')` returns a value on your checkout page (it returns `null` while consent is required and not yet given). - **Subscriptions missing**: check that the subscription events are selected on the endpoint. See also [Troubleshooting](https://supametrics.io/docs/troubleshooting). --- This is one page of the Supametrics help center (section: Revenue). - Index of every page: https://supametrics.io/llms.txt - Every page in one file: https://supametrics.io/llms-full.txt