Client-side tracking
This feature is only available on Business plans and above .
RevRoute’s powerful attribution platform lets you understand how well your links are translating to actual users and revenue dollars.
In this guide, we’ll learn how to track conversion events with RevRoute using client-side tracking.
Client-side conversion tracking comes with the following limitations:
- Ad blockers – Users with ad blockers may prevent tracking scripts from loading.
- JavaScript disabled – Events won’t be tracked if users have JavaScript disabled.
- Network issues – Failed network requests won’t retry automatically.
- Privacy concerns – Some users may block client-side tracking for privacy reasons.
For more accurate conversion tracking, consider using server-side conversion tracking.
Step 1: Enable conversion tracking for your links
First, enable conversion tracking for your links — without it a click is never linked to the lead and sale events that follow.
You can skip this step for partner program links: RevRoute enables conversion tracking on them automatically.
For the whole workspace. Open Settings → Analytics and turn on the Conversion tracking switch in the page header — it controls the workspace-level setting. Every link created from that point on has conversion tracking enabled.
For a single link. Open the
link builder and turn
on the Conversion tracking switch — inside the builder it is also bound to
the C keyboard shortcut.
Via the API. Pass trackConversion: true when creating or updating a link
(it defaults to false):
curl -X POST "https://api.revroute.ru/links" \
-H "Authorization: Bearer rr_xxxxxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"trackConversion": true
}'Step 2: Install the RevRoute Analytics script
Allowlist your site's domain
Client-side events are only accepted from allowed hosts — this keeps your publishable key from being used on someone else’s site.
Open Settings → Analytics and add your site’s domain to the Allowed hostnames list:
example.com— that domain only;*.example.com— all subdomains, but notexample.comitself.
While testing locally you can add localhost — remember to remove it before
going live.
Generate a publishable key
In the same place, under the Install the RevRoute client-side script step,
turn on the Conversion tracking switch and generate a publishable key — a key
that looks like rr_pk_.... Unlike the secret key (rr_*), it is safe to
expose in the browser.
Install the script with the key
Client-side conversion tracking runs in a separate build of the script,
script.conversion-tracking.js. The key goes into the data-publishable-key
attribute:
<script
defer
src="https://app.revroute.ru/analytics/script.conversion-tracking.js"
data-api-host="https://api.revroute.ru"
data-publishable-key="rr_pk_xxxxxxxx"
></script>Without data-publishable-key the script still counts clicks, but no lead or
sale events can be sent from the client.
The script adds trackLead and trackSale methods to
window.revRouteAnalytics — that is how events are sent.
Step 3: Track lead events
Looking to track sales without a prior lead event? Pass clickId directly
alongside customer details when calling track/sale — see the API
reference for full details.
Once the script is installed, lead events are sent with
revRouteAnalytics.trackLead — usually from a thank-you page or a form handler.
<script>
const params = new URLSearchParams(window.location.search);
const email = params.get("email");
if (email) {
window.revRouteAnalytics.trackLead({
eventName: "Sign Up",
customerExternalId: email,
customerEmail: email,
customerName: params.get("name") || undefined,
});
}
</script>The same thing in React, in the success handler of your form:
function SignUpForm() {
const handleSubmit = async (e) => {
e.preventDefault();
await createAccount({ name, email }); // your own backend call
// only send the event once the backend confirmed the signup
window.revRouteAnalytics.trackLead({
eventName: "Sign Up",
customerExternalId: email,
customerEmail: email,
customerName: name,
});
};
return <form onSubmit={handleSubmit}>{/* form fields */}</form>;
}You don’t pass clickId: the script fills it in from the rr_id cookie. The
remaining fields match the server-side /track/lead request.
Send the event only after your backend has confirmed the signup, otherwise analytics fills up with leads that never happened.
Step 4: Track sale events
Sale events work the same way — call revRouteAnalytics.trackSale after a
successful payment:
<script>
window.revRouteAnalytics.trackSale({
customerExternalId: "cus_oFUYbZYqHFR0knk0MjsMC6b0",
amount: 499000, // amount in minor units: 4,990 RUB
currency: "RUB",
eventName: "Purchase",
paymentProcessor: "yookassa",
invoiceId: "inv_8f2b1c", // idempotency key: one sale per invoice
});
</script>What matters in the payload:
amount— an integer in the currency’s minor units (kopecks for roubles).currency— an ISO 4217 code,rubby default; the amount is stored in the currency you send, without conversion.paymentProcessor—yookassa,stripe,shopify,polar,paddle,revenuecatorcustom(the default).invoiceId— the invoice ID; calling again with the same value does not create a second sale.
A client-side call is trivial to forge from the browser. For anything involving money, server-side tracking is safer: the amount comes from your backend rather than from page code.
Looking to track refunds? Use the PATCH /commissions/{id}
endpoint to mark the corresponding
commission as refunded when your billing webhook fires a refund event.
Step 5: View your conversions
And that’s it – you’re all set! You can now sit back, relax, and watch your conversion revenue grow. We provide 3 different views to help you understand your conversions:
- Time series — clicks, leads and sales over time: Analytics .
- Funnel — conversion and drop-off at every step (clicks → leads → sales): Analytics in funnel mode .
- Events stream — every conversion event across all links in the workspace, in real time: Events .