Learn how to track lead conversion events with Auth0 and LinkKit
When tracking conversions, a lead event is triggered when a user takes an action that shows interest in your product or service. Common examples of lead conversion actions include:
- Creating an account
- Scheduling a demo meeting
- Subscribing to a mailing list
These events help you identify potential customers and measure how effectively your marketing efforts are driving user engagement.
In this guide, we’ll focus on tracking new user sign-ups for a SaaS application that uses Auth0 for user authentication.
Prerequisites
Before you can start tracking conversions, you’ll need to enable conversion tracking for your LinkKit links.
Once enabled, LinkKit can capture and attribute user sign-up events to the links that drive those conversions.
Option 1: Enable Conversion Tracking at the Workspace Level
Go to your workspace’s Tracking Settings page.
Turn on the Workspace-level Conversion Tracking option.
After enabling this setting, all future links created in the workspace will have conversion tracking enabled by default.
Option 2: Enable Conversion Tracking at the Link Level
To enable conversion tracking for an individual link:
Open the LinkKit Link Builder for the link you want to track.
Enable the Conversion Tracking toggle.
This gives you control over which links should collect and attribute conversion data.
Option 3: Enable Conversion Tracking via the API
When creating or updating a link, include the trackConversion: true parameter in your API request. This will activate conversion tracking for that specific link automatically.
Once conversion tracking is enabled, you’ll need to add the LinkKit Analytics script to your website to start capturing conversion events.
You can install the LinkKit Analytics script using different methods depending on your website setup and technical requirements.
Add the ?linkkit_id=test query parameter to your website URL and verify that the linkkit_id cookie is being created in your browser.
If both checks are successful, the analytics script has been installed correctly.
If the verification fails, check the following:
Ensure the analytics script has been added inside the page’s <head> section.
If your website uses a content delivery network (CDN), clear or purge the cache to make sure the latest changes are applied.
Configure Auth0
Next, configure Auth0 to track lead conversion events.
Here’s how the process works:
- In the afterCallback function, detect whether the user has completed a new sign-up.
- If the user is signing up for the first time, check whether the linkkit_id cookie is available.
- If the linkkit_id cookie exists, send a lead event to LinkKit using linkkit.track.lead.
- Remove the linkkit_id cookie after the event has been recorded.
This ensures that new user registrations are properly tracked and attributed to the correct link conversion.
import { handleAuth, handleCallback, type Session } from "@auth0/nextjs-auth0";
import { cookies } from "next/headers";
import { linkkit } from "@/lib/linkkit";
const afterCallback = async (req: Request, session: Session) => {
const userExists = await getUser(session.user.email);
if (!userExists) {
createUser(session.user);
// Check if linkkit_id cookie is present
const clickId = cookies().get("linkkit_id")?.value;
if (clickId) {
// Send lead event to LinkKit
await linkkit.track.lead({
clickId,
eventName: "Sign Up",
customerExternalId: session.user.id,
customerName: session.user.name,
customerEmail: session.user.email,
customerAvatar: session.user.image,
});
// Delete the linkkit_id cookie
cookies().set("linkkit_id", "", {
expires: new Date(0),
});
}
return session;
}
};
export default handleAuth({
callback: handleCallback({ afterCallback }),
});
Lead Event Properties
The following properties can be included when sending a lead event:
View Your Conversions
After completing the setup, all tracked conversion events will appear in LinkKit Analytics.
LinkKit provides three different views to help you analyze and understand your conversions:
Time-Series View
A time-based view that displays the number of:
- Clicks
- Leads
- Sales
This helps you track conversion trends and measure how users move through your funnel over time.
Funnel Chart View
A visual representation of your conversion funnel that shows conversion and drop-off rates across each stage of the customer journey:
Clicks → Leads → Sales
This view helps you understand how users progress through the funnel, identify where potential customers are dropping off, and optimize each step to improve conversions.
Real-Time Events Stream
A live feed that displays every conversion event recorded across all links in your workspace.
This view provides instant visibility into:
- Lead events being captured.
- Sales events being tracked.
- Conversion activity from all your links in real time.
Use the real-time events stream to monitor incoming conversions, verify tracking setup, and stay updated on user actions as they happen.
