Attribute revenue with Stripe (other methods)
Attribute any Stripe payment, from custom checkouts to mobile, through the customer's email.
Make sure you've connected your Stripe account first.
When you can't pass metadata, credit the payment through the customer's email. On the page buyers land on after paying, call:
js
// On your success page, once you know who paid
window.datasense("payment", { email: customer.email })Datasense matches it to the Stripe payment with that email, whether the webhook arrived before or after.
Example
Say buyers are redirected to /welcome after checkout. In React:
components/payment-tracker.jsx
"use client"
import { useEffect } from "react"
export function PaymentTracker({ email }) {
useEffect(() => {
window.datasense?.("payment", { email })
}, [email])
return null
}Make it reliable
If the call can run before the script has loaded, add this to the page's <head>, above the script, so the call is queued:
html
<script>
window.datasense = window.datasense || function () {
(window.datasense.q = window.datasense.q || []).push(arguments)
}
</script>When to use it
- Custom checkouts, Stripe Elements and third-party tools built on Stripe
- Mobile app payments
The email is matched as a SHA-256 hash and never stored in plain text.