Skip to Content
Developer DocsWeb installationServer-side tracking (recommended)

Server-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 server-side tracking.

📝

The recommended way to track conversions on RevRoute is using server-side tracking, which is more reliable than client-side tracking.

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

Next, you’ll need to install the RevRoute Analytics script.

This script detects the rr_id query parameter and storing it as a first-party cookie, which will be used to attribute subsequent conversion events to the original link.

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:

  1. Open the browser console and type _revRouteAnalytics — if the script is installed, the object shows up in the console.
  2. Add the ?rr_id=test query parameter to your site URL and check that the rr_id cookie 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.

Step 3: Call the tracking endpoints from your backend

Server-side conversion tracking is two plain HTTPS requests, so you can call it from any language or framework:

Authenticate both with your workspace API key in the Authorization: Bearer header.

Step 4: Track conversion events

Now comes the fun part – tracking conversion events.

Tracking lead events

The first event you’ll want to track is a lead event. This happens when a user performs an action that indicates interest in your product or service. This could be anything from:

  • Signing up for an account
  • Adding a product to cart
  • Joining a mailing list

Our most common lead event is Sign Up, which happens when a user signs up for an account. Depending on which authentication framework you’re using, here are a few examples of how to send Sign Up lead events:

Clerk

Better Auth

NextAuth.js

Supabase

Auth0

Appwrite

Not using any of these? Send the event as a plain HTTP request from any language — POST /track/lead with your secret key in the Authorization header.

The lead event will serve as the source of truth for the customer’s identity and which link they came from. This means that all subsequent actions performed by the customer (e.g. upgrading their plan, purchasing a product) will automatically be attributed to the original link.

Tracking sale events

The second event you’ll want to send is a sale event. This happens when a user purchases your product or service. This could be anything from:

  • Subscribing to a paid plan
  • Usage expansion (upgrading from one plan to another)
  • Purchasing a product

You can send sale events from your backend after a successful payment with a POST /track/sale request. The most common pattern is to call track/sale from a payment-webhook handler (e.g. payment.succeeded from YooKassa or your own internal billing webhook).

💡

Looking to track sales without a prior lead event? Pass clickId directly alongside the customer details when calling track/sale.

Step 5: View your conversions

Once you’ve enabled conversion tracking for your links, all your tracked conversions will show up on your Analytics dashboard . 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 .
Last updated on