Next.js + Clerk
Tracks signups from Clerk’s user.created webhook in a Next.js app.
What it does
- Your server sends the lead from the
user.createdwebhook, which settles it. - The click reaches the webhook through the Clerk user’s metadata, since a webhook has no browser cookie.
- Clicks and sales work as in the Next.js guide.
Set up in three steps
- Install
@affitor/sdkand wrap your app inAffitorProviderwith your program ID, as in the Next.js guide. - Before sign-up completes, store the click ID on the Clerk user with
signUp.update({ unsafeMetadata }). - In your
user.createdwebhook, calltrackLeadwith the Clerk user ID and that click ID. Use the same ID at sale time.