VisitTrack
Start free
☰ Browse the docs

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

  1. In VisitTrack, open Settings → Revenue and pick Razorpay.
  2. Copy the webhook URL shown there. It looks like https://visitrack.app/api/razorpay-webhook/YOUR_SITE_ID.
  3. In Razorpay: Account & Settings → Webhooks → Add new webhook, with a secret of your choice. Paste the URL and subscribe to payment.captured and refund.processed.
  4. 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

EventWhat VisitTrack does
payment.capturedRecords the payment (amount, currency, email) against the visitor in notes.visitrack_visitor_id.
refund.processedSubtracts the refund from the original payment. refund.created is ignored, because a refund can still fail at that point.
anything elseAcknowledged with 200 and ignored.

Test it

  1. 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).
  2. Complete a checkout in test mode.
  3. 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.