DocsMeasure
Stripe connector
Connect Stripe with a read-only key. Payments, refunds and subscriptions tie to the visits, ads and links that brought each customer, with MRR kept current.
On this page
The Stripe connector reads your payments, refunds and subscriptions. Each one ties to the customer who paid, and to the visits, ads and short links that brought them. You see it on the Revenue page, on each customer profile, in the attribution report, and live sales go to your ad accounts.
It is on paid plans: Solo, Studio, Agency and Custom. Free does not include it.
Connect with Stripe (when shipped). A one-click login: click Connect, log in to Stripe in the new tab and allow read access, and you are done, with no key to paste. Until it is switched on, use the steps below.
Datacenter only reads. The key you give it cannot charge, refund or change anything in Stripe.
Connect
1. In Datacenter, open your site, then Settings, then Integrations. Next to Stripe, click Connect. 2. In Stripe, open API keys and click Create restricted key. If Stripe asks how you will use the key, pick the option for another app or website. 3. Name it Datacenter. Set these to Read and leave everything else at None: - Customers - Charges - PaymentIntents - Checkout Sessions - Invoices - Refunds - Subscriptions - Balance, only for Stripe fees in investor costs. Without it everything else still syncs. 4. Click Create key. Stripe may ask for a code it sends you. Copy the key. It starts with rk_live_. 5. Paste it into Datacenter and click Connect Stripe.
Datacenter checks that the key can read each of the first seven. If one is missing, it says which one. Without Balance, the Costs page under Investors says so. Use a test key (rk_test_) to try it with test data first.
Do not paste your secret key (sk_live_). It can do anything in your account, so Datacenter refuses it.
What happens next
- The first import reads the last 90 days of payments and refunds, and every subscription you have, whatever its age, so MRR starts right. A busy account can take a few hours, since each run reads a small batch. Integrations shows Importing and a count.
- After that, Datacenter checks for new payments and plan changes every 15 minutes.
- Sync now starts a check at once.
The key is stored encrypted. It is never shown again, and it never appears in logs.
Tie payments to visits
A payment ties to the visits before it when Stripe knows the visitor's id. This needs the site in 90-day tracking.
Payment Links, Buy Buttons and pricing tables: nothing to do. Once Stripe is connected, the Datacenter tag adds the visitor's id to every buy.stripe.com link on your pages as client_reference_id, and sets client-reference-id on Stripe Buy Buttons and pricing tables. It never replaces an id you set yourself, and on a site that waits for consent it waits too. Stripe reads the Buy Button and pricing table attribute when they first draw, so keep the Datacenter tag above Stripe's script on the page.
Checkout from your own code: one line. Where you create the Checkout Session, pass the _dc_id cookie:
const session = await stripe.checkout.sessions.create({
// ...your line items, mode and URLs
client_reference_id: req.cookies._dc_id,
});metadata: { dc_id: req.cookies._dc_id } works too, on a Checkout Session, a PaymentIntent or a subscription. Datacenter only takes an id that looks like one of its own (32 letters and numbers), so a client_reference_id you use for your own order numbers is left alone.
Without the id, Datacenter still ties a payment when:
- the Stripe customer paid before and was tied to a visit then, or
- the email on the payment is one the person gave on your site, in a form Datacenter reads or through
datacenter('identify', ...).
The Revenue page says how many payments are tied, and how. A payment that is not tied still counts in revenue and MRR, under Direct.
Instant updates (optional)
Without a webhook, new sales and plan changes show up within 15 minutes. With one, they show up in seconds, and a live sale goes to your ad accounts right away.
1. Open the Stripe connector's page in Datacenter (Settings next to Stripe). Copy the Endpoint URL. It looks like https://datacenter.so/hooks/stripe/.... 2. In Stripe, open Webhooks and add an endpoint. Stripe may call it an event destination. 3. Pick these events: - checkout.session.completed - charge.succeeded - charge.refunded - invoice.paid - customer.subscription.created - customer.subscription.updated - customer.subscription.deleted 4. Paste the endpoint URL and save. 5. Reveal the endpoint's Signing secret (it starts with whsec_), copy it, and paste it into Datacenter under Instant updates.
Set up before customer.subscription.updated was on this list? Add it to your endpoint in Stripe. Until you do, upgrades and downgrades show up with the 15-minute check.
Datacenter checks the signature on every webhook and refuses any that do not match. It then reads the object again from Stripe with your key, so it never trusts the webhook body alone. Each event is handled once: when Stripe sends the same event id again, Datacenter answers and changes nothing.
What shows up on a customer
| Stripe | On the customer |
|---|---|
| A paid Checkout Session | Order, with the amount and product names |
| A paid invoice | Order, or Subscription renewed for a renewal |
| A payment with no session or invoice | Order |
| A refund | Refund, which lowers revenue |
| A new subscription | Subscription started, with the plan |
| An upgrade or downgrade | Plan changed, with the change to MRR |
| A canceled subscription | Subscription canceled |
One payment is one order. A Checkout Session, its PaymentIntent, its charge and its invoice are linked, so Stripe telling us about each of them never counts the sale twice.
Orders and revenue add up into the customer's lifetime value. Revenue adds up in the customer's first currency.
Who the customer is
Datacenter finds the customer by:
- the Stripe customer id,
- the email and phone on the payment (hashed with SHA-256, the way Meta asks),
- the visitor's id, from
client_reference_idormetadata.dc_id.
Goals, Meta and your ad accounts
Synced sales count as the Purchase event. They reach any goal on the event Purchase.
A new sale goes once to Meta when that goal sends to Meta, and once to each ad account turned on under Send results to your ad accounts when that goal is ticked there:
- Only live sales: ones that happened in the last 24 hours. The 90-day import never sends old sales.
- Renewals are not sent. They are not new buyers.
- The hashed email and phone go along, and the ad click ids (such as
gclidorttclid) from any visit tied to the buyer, so the platform can match the sale to its click. - A refund of a sale that was sent lowers its value in Google Ads and Microsoft Ads. See Refunds.
- A sale the browser or the Events API already sent under the same id is not sent again, and the other way round.
The event_id rule
Meta, the other platforms and Datacenter all count a sale once per event_id. The Stripe connector uses the Stripe object id:
| Sale | event_id |
|---|---|
| Stripe Checkout | The Checkout Session id, cs_... |
| A paid invoice | The invoice id, in_... |
| Any other payment | The PaymentIntent id, pi_... |
If you also send the sale from the browser or the Events API, use the same id as event_id. For Checkout, your success page gets the session id when the success URL has ?session_id={CHECKOUT_SESSION_ID}:
datacenter('Purchase', { event_id: sessionId, value: 49, currency: 'USD' });
fbq('track', 'Purchase', { value: 49, currency: 'USD' }, { eventID: sessionId });Then:
- Datacenter sees the same id from both and counts the order once on the customer.
- A sale already sent from the browser or the Events API is not sent again by the connector, and the other way round.
- Meta also drops the second copy it gets from the pixel.
An order_id that matches one of the Stripe ids is treated the same way.
The attribution report
Synced sales appear in the attribution report on their real date, under All goals and under a goal on Purchase. A sale that your site also sent as an event, with the same event_id or order_id, is counted once.
Synced sales do not change your visitor stats and do not count toward your plan's events.
Sync log
The connector's page lists the last 50 runs and webhooks: what was added and any errors. Keys and personal data are never shown there. Rows older than 30 days are deleted.
If something goes wrong
Integrations shows Needs attention with the reason:
- Stripe did not accept the key. It was deleted or expired. Make a new restricted key and paste it under Paste a new key.
- The key cannot read Invoices (or another resource). Edit the key in Stripe and set it to Read.
- Stripe is busy right now. Nothing to do. Datacenter tries again every 15 minutes. This shows only after 6 hours with nothing read; a shorter outage is in the sync log alone.
- Paused. Connectors are on paid plans. The plan changed to Free. Sync starts again after an upgrade.
Disconnect
Click Disconnect on the connector's page. The key and the signing secret are deleted at once, and the tag stops adding ids to Stripe links within a few minutes. Orders already imported stay on your customers. To remove one person's data, use Delete this customer on their profile. Delete the restricted key and the webhook in Stripe too.
If you connect again later, the endpoint URL stays the same.
Something missing or wrong? Email hello@datacenter.so.