Auth0

Learn how to track lead conversion events with Auth0 and LinkKit

Learn how to track lead conversion events with Auth0 and LinkKit

Business Plan Requirement
This feature is only available on LinkKit Business plans and above.

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.

LinkKit Partners
If you're using LinkKit Partners, you can skip this step since partner links will have conversion tracking enabled by default.
Option 1: Enable Conversion Tracking at the Workspace Level
To automatically enable conversion tracking for all new links created within a workspace:

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
If you prefer not to enable conversion tracking for every link in your workspace, you can activate it only for specific links.

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
You can also enable conversion tracking programmatically using the LinkKit 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.

You can confirm that the LinkKit Analytics script is installed correctly by completing the following checks:
Open your browser’s developer console and enter _linkkitAnalytics. If the script is working properly, you should see the _linkkitAnalytics object displayed.
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:

Property

Required

Description

clickId

Yes

The unique click identifier used to attribute the lead conversion event. This value can be retrieved from the linkkit_id cookie. If an empty value is provided (for example, when using deferred lead tracking), LinkKit will attempt to locate an existing customer using the provided customerExternalId and reuse the associated click ID if available.

eventName

Yes

The name of the lead event being tracked. It can also act as a unique identifier to associate a lead event with a customer for a future sale event using the leadEventName property in /track/sale.

customerExternalId

Yes

The unique identifier of the customer in your system. This is used to identify the customer and attribute future conversion events to them.

customerName

No

The customer's name. If not provided, a generated name will be assigned automatically.

customerEmail

No

The customer's email address.

customerAvatar

No

The customer's avatar or profile image URL.

mode

No

Defines how the lead event is processed. async sends the event without waiting for completion, wait waits until the event is fully recorded, and deferred delays lead creation until a later request.

metadata

No

Additional data to store with the lead event. Maximum limit: 10,000 characters.

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.