Learn how to track lead conversion events with NextAuth.js and Dub
lead
event happens when a user performs an action that indicates interest in your product or service. This could be anything from:
dub
TypeScript SDK.
Here’s how it works in a nutshell:
signIn
event to detect when there’s a new sign up.dub_id
cookie is present.dub_id
cookie is present, send a lead event to Dub using dub.track.lead
dub_id
cookie.dub_id
cookie anymore.
isNewUser
flag will only be available if you’re using
next-auth
’s database
implementation
(otherwise it’ll return undefined
). In that case, you should move the logic
above to the signIn
callback
instead.Property | Required | Description |
---|---|---|
clickId | Yes | The unique dub_id parameter that the lead conversion event is attributed to. |
eventName | Yes | The name of the event. Example: “Sign up”. |
customerExternalId | Yes | The unique ID of the customer in your system. Will be used to identify and attribute all future events to this customer. |
customerEmail | No | The email address of the customer. If not passed, a random email address will be generated. |
customerName | No | The name of the customer. If not passed, a random name will be generated (e.g. “Big Red Caribou”). |
customerAvatar | No | The avatar URL of the customer. If not passed, a random avatar URL will be generated. |
authOptions
variable you created earlier and use NextAuth
to create a handler for your NextAuth.js routes.