Revenue attribution
Razorpay
Attribute captured Razorpay payments created through the Orders API.
Snippets use YOUR_SITE_ID as a placeholder. Sign in and they're filled in with your real site id.
1. Connect Razorpay
- In VisitTrack, open Settings → Revenue and pick Razorpay.
- Copy the webhook URL shown there. It looks like
https://visitrack.app/api/razorpay-webhook/YOUR_SITE_ID. - In Razorpay: Account & Settings → Webhooks → Add new webhook, with a secret of your choice. Paste the URL and subscribe to
payment.capturedandrefund.processed. - Copy the same webhook secret Razorpay gives you back into VisitTrack and press Connect. It's stored encrypted and only used to verify signatures.
2. Pass the visitor id
Put it in the order's notes. Razorpay copies order notes onto the payment. You can also set them in the Checkout options.
const order = await razorpay.orders.create({
amount: 49900,
currency: "INR",
notes: { visitrack_visitor_id: visitorId ?? "" },
});Events
| Event | What VisitTrack does |
|---|---|
payment.captured | Records the payment (amount, currency, email) against the visitor in notes.visitrack_visitor_id. |
refund.processed | Subtracts the refund from the original payment. refund.created is ignored, because a refund can still fail at that point. |
| anything else | Acknowledged with 200 and ignored. |
Test it
- Open your site in a normal browser tab so the tracker records a visit (localhost is ignored unless the script tag has
data-allow-local). - Complete a checkout in test mode.
- Open Revenue in the dashboard. The payment shows up within a few seconds, with the referrer, campaign and landing page that brought that visitor in.
Nothing showed up?
See Missing or unattributed payments. The webhook response body always says why a payment was skipped.
Something missing? Tell us.
AI agent or LLM? Read this page as markdown.