Conversion tracking require a Business plan subscription or higher.

When it comes to conversion tracking, a lead event 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

In this guide, we will be focusing on tracking new user sign-ups for a SaaS application that uses Segment to collect customer data.

Prerequisites

Before you get started, make sure you follow the Dub Conversions quickstart guide to get Dub Conversions set up for your links:

  1. Enable conversion tracking for your links
  2. Install the @dub/analytics client-side SDK

Configure Segment Action

Next, configure Segment Dub (Actions) to track lead conversion events.

1

Add Dub (Actions) destination

Head to Segment Dub (Actions) and add the destination to your Segment workspace.

2

Configure Dub API Key

In the Dub (Actions) destination settings, fill out the following fields:

  • Name: Enter a name to help you identify this destination in Segment.
  • API Key: Enter your Dub API key. You can find this in the Dub Dashboard.
  • Enable Destination: Toggle this on to allow Segment to send data to Dub.

Once completed, click Save Changes.

3

Add Mapping

Next, you’ll choose the Track a lead action from the list of available actions.

By default, this action is configured to send lead data to Dub when the Event Name is Sign Up.

Below the selected action, you’ll see the mapping for that action.

You can customize the trigger and mapping to fit the specific needs of your application.

Finally, click Next and then Save and enable to add the mapping to the destination.

4

Send lead events to Dub

On the server side, you’ll use the @segment/analytics-node SDK to send lead events to Segment.

Make sure to include relevant user traits such as name, email, and clickId in the payload.

You’ll also need to ensure that the clickId field is properly mapped in your Segment Actions destination so that it’s forwarded correctly to Dub.

import { Analytics } from "@segment/analytics-node";

const segment = new Analytics({
  writeKey: "<YOUR_SEGMENT_WRITE_KEY>",
});

const cookieStore = await cookies();
const clickId = cookieStore.get("dub_id")?.value;

segment.track({
  userId: id,
  event: "Sign Up",
  context: {
    traits: {
      name,
      email,
      avatar,
      clickId,
    },
  },
  integrations: {
    All: true,
  },
});

Once the event is tracked, Segment will forward the lead data to Dub based on the mappings you’ve configured.

Here’s the full list of attributes you can pass when sending a lead event:

PropertyRequiredDescription
clickIdYesThe unique dub_id parameter that the lead conversion event is attributed to.
eventNameYesThe name of the event. Example: “Sign up”.
externalIdYesThe unique ID of the customer in your system. Will be used to identify and attribute all future events to this customer.
customerEmailNoThe email address of the customer. If not passed, a random email address will be generated.
customerNameNoThe name of the customer. If not passed, a random name will be generated (e.g. “Big Red Caribou”).
customerAvatarNoThe avatar URL of the customer. If not passed, a random avatar URL will be generated.

Example App

To learn more about how to track leads with Segment, check out the following example app:

Segment + Next.js App Router Example

Next.js app using Segment to track new user sign-ups.

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:

  • Funnel chart: A funnel chart view visualizing the conversion & dropoff rates across the different steps in the conversion funnel (clicks → leads → sales).
  • Real-time events stream: A real-time events stream of every single conversion event that occurs across all your links in your workspace.