Deferred lead tracking
Conversion tracking is available on the Business plan and above .
In conversion tracking, a lead event is an
action that signals interest in your product:
- signing up for an account;
- booking a demo;
- joining a mailing list.
The lead event establishes the customer’s identity and the link they came from: every later action (a purchase, a plan upgrade) is attributed to that same link.
However, there are times where signups alone might not be the clearest indicator of a lead conversion event. For instance, you might want to track a more meaningful lead event such as:
- A user completing their first meeting on Granola
- A user making their first search query on Perplexity
- A user dictating their first 2,000 words on Wispr Flow
In these cases, you can use deferred lead tracking to defer the actual lead event creation to a subsequent request:
![]()
Deferred lead tracking is particularly useful for tracking sales-qualified leads (SQLs) – both for marketing attribution purposes, as well as to make sure that you’re rewarding partners for qualified leads (instead of just pure signups) with RevRoute Partners .
Prerequisites
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
}'Then install the RevRoute client-side script on your site — it records the click and stores its ID, which is what lead events are attached to.
The RevRoute client-side script is served from our domain — there are no npm
packages to install. It picks up the rr_id query parameter, stores it in a
first-party rr_id cookie on your domain (90 days) and uses it to attribute
future conversions to the original link.
Add the tag to the <head> section of every page on your site:
<script defer src="https://app.revroute.ru/analytics/script.js"></script>In Next.js (App Router), use next/script in the root layout:
import Script from "next/script";
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
<Script defer src="https://app.revroute.ru/analytics/script.js" />
</html>
);
}You can verify the installation in two ways:
- Open the browser console and type
_revRouteAnalytics— if the script is installed, the object shows up in the console. - Add the
?rr_id=testquery parameter to your site URL and check that therr_idcookie is set in your browser.
If neither works, make sure that:
- the script tag sits in the
<head>section of the page; - any CDN cache in front of your site has been purged.
The server-side client
The examples below use the TypeScript SDK from the dub npm package. Always
pass the RevRoute API serverURL to the client — without it the SDK will not
talk to our API.
npm install dubimport { Dub } from "dub";
export const revroute = new Dub({
token: process.env.REVROUTE_API_KEY, // secret rr_* key from your workspace settings
serverURL: "https://api.revroute.ru", // required: the RevRoute API address
});Keep the secret key (rr_*) in environment variables and never expose it to
the browser. Create one under API keys .
The SDK is optional: /track/lead and /track/sale are plain HTTPS endpoints
you can call from any language.
Step 1: Track a deferred lead event
First, when the user completes the action that indicates interest in your product or service, you’ll need to track a deferred lead event. Examples include:
- Signing up for an account
- Booking a demo meeting
- Joining a mailing list
To do this, you’ll need to set the mode property to deferred when tracking the lead event. With this, RevRoute will still track the customer and the click ID they came from, but defer the actual lead event creation to a subsequent request.
import { RevRoute } from "dub";
const dub = new RevRoute();
const clickId = req.cookies["rr_id"];
if (clickId) {
await dub.track.lead({
clickId: clickId,
mode: "deferred",
eventName: "Sign Up",
customerExternalId: customer.id,
customerName: customer.name,
customerEmail: customer.email,
customerAvatar: customer.avatar,
});
// delete the rr_id cookie
res.cookies.set("rr_id", "", {
expires: new Date(0),
});
}Step 2: Track a qualified lead event
Once the user completes the action that makes them a qualified lead, you can then track a qualified lead event. To do this, you’ll repeat the same lead tracking request as before, but without the mode property and by setting the clickId property to an empty string.
import { RevRoute } from "dub";
const dub = new RevRoute();
await dub.track.lead({
clickId: "",
eventName: "Sign Up",
customerExternalId: customer.id,
customerName: customer.name,
customerEmail: customer.email,
customerAvatar: customer.avatar,
});Where to see conversions
Once everything is set up, tracked conversions show up in your workspace analytics in three views:
- 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 .