Payment providers
Razorpay revenue attribution with CrispStats
Connect Razorpay in CrispStats by pasting your live key ID and key secret, then put the visitor id in the order's or subscription's notes as crispstats_visitor_id. CrispStats imports your past payments and refunds, then reads new ones from Razorpay's API every 2 minutes, and credits each to the visit that led to it.
Updated
Set up CrispStats on Razorpay
- 01
Step 1: Open the Razorpay panel
The CrispStats script must already run on your site. Open the site’s Settings, select Integrations, choose Connect a payment provider and pick Razorpay. You need permission to manage the site’s settings.
- 02
Step 2: Find your live key
Select Open API keys in Razorpay. Switch to Live mode, then open Account and Settings, API keys (you need the Owner or Admin role). Copy the key ID, which starts with
rzp_live_, and the key secret you saved when you created it. If you no longer have the secret, generate a new one, keep the old key for 24 hours if Razorpay offers it, and update your checkout before then. - 03
Step 3: Paste the key ID and secret
Paste them into Razorpay key ID and Razorpay key secret, then select Connect Razorpay. CrispStats checks the pair with Razorpay, saves the secret encrypted and starts importing past payments and refunds.
- 04
Step 4: Pass the visitor id at checkout
Call
crispstats.id()in the browser before Checkout opens, send it to your server, and put it in the order’snotes. For a subscription, put it in the subscription’snotes. The notes of the payment, its order, subscription or invoice, and the refund are all read.checkout.js// In the browser, before you open Checkoutconst visitorId = await crispstats.id();// On your server, when you create the orderconst order = await razorpay.orders. create( {amount: 49900,currency: "INR",notes: { crispstats_visitor_id: visitorId },});// Subscriptions: in the subscription's notes insteadconst subscription = await razorpay. subscriptions. create( {plan_id: "plan_...",total_count: 12,notes: { crispstats_visitor_id: visitorId },});
Check that it works
The Razorpay row in Settings, Integrations shows Connected, whether it is live, and when it last updated. Make a purchase from a page with the script: it appears under Payments on the Revenue screen with the source of that visit. If the key stops working or loses a permission, the row says so and names the way out.
CrispStats on Razorpay
What you get
- Razorpay revenue by source, channel, campaign and landing page, credited to the first touch known for the customer.
- Every captured payment read from Razorpay’s API, so each counts as verified revenue, with orders, first subscription charges and renewals kept apart.
- Payments of Razorpay Invoices recorded as one-time payments, with the invoice’s notes.
- Processed refunds recorded as negative payments; refunds of payments that were never captured are skipped.
- Past payments and refunds imported when you connect, so revenue and MRR cover your whole history.
Notes and limits
- Razorpay does not let an account’s own keys create a webhook, so CrispStats reads new payments and refunds every 2 minutes. A sale appears within 2 minutes. A payment captured later than it was created is still caught, and a daily check reads the last 48 hours again.
- Razorpay keys cannot be limited to reading. CrispStats uses the key only to read payments and refunds; the secret is stored encrypted and never shown again. The key ID is not secret: Razorpay shows it in your checkout pages.
- A test key connects in test mode once you choose Connect in test mode. Test payments show with a Test tag on the Revenue screen and are kept out of revenue, MRR and every total.
- A payment without a visitor id is still recorded and counted in revenue, MRR and every total. It is left out of the source, campaign and channel breakdowns rather than filed under Direct.
- Connections made earlier with a webhook you added in Razorpay keep working, but cannot import history or verify payments. Connect again with your key ID and secret to add both; a payment seen by the webhook and by a check is stored once.
- CrispStats does not calculate churn or expansion. Razorpay stays the source of truth for settlements and disputes.
The docs page covers the optional steps this guide leaves out.
Setup questions. Straight answers.
What people ask before they connect it.
Razorpay does not let an account's own keys create a webhook, so CrispStats reads new payments every 2 minutes instead. Each payment is read from Razorpay's API, so it counts as verified revenue.
In the subscription's notes, when you create it on your server. Every charge of the subscription then carries the id, so renewals are credited to the same first visit.
Yes. Connecting starts the import at once: every captured payment and processed refund since your first.
CrispStats stops reading payments and destroys the saved secret. It created nothing in your Razorpay account, so there is nothing to delete there. Payments already recorded stay.
Yes, history import included. Every feature is on every plan and in the 14-day free trial, and payments are kept on every plan.
Not answered here? Write to hello@crispstats.com
Go further
Related
- Revenue attribution: which traffic pays
See which source, page and campaign each payment came from.
- First touch vs last touch attribution
First touch, last touch and multi-touch attribution in plain terms, with a worked example and how to join a payment to the visit that caused it.
- Web analytics for SaaS products
See which channels bring paying customers, where trials stall in the funnel, and how your app performs for real users, from one cookieless script.
- Revenue per visitor calculator
Enter visitors, conversion rate and average order value to get revenue per visitor, monthly revenue, and what a 10% improvement is worth.
Other integrations
Payment providers
Frameworks
Site builders
Ecommerce platforms
Tag managers
Your traffic, crisp and clear
One script, no cookies, and every feature from the first day. Set up takes about as long as pasting a snippet.