Skip to Content
Документация для разработчиковОтслеживание конверсийLeadsAuth0

В этом руководстве мы сосредоточимся на отслеживании регистраций новых пользователей для SaaS-приложения, использующего Auth0 для аутентификации.

Настройка Auth0

Далее настройте Auth0 для отслеживания событий конверсий лидов.

Вот как это работает в двух словах:

  1. In the sign in afterCallback function, check if the user is a new sign up.
  2. If the user is a new sign up, check if the dub_id cookie is present.
  3. If the dub_id cookie is present, send a lead event to Revroute using dub.track.lead
  4. Delete the dub_id cookie.
import { handleAuth, handleCallback, type Session } from "@auth0/nextjs-auth0"; import { cookies } from "next/headers"; import { dub } from "@/lib/dub"; const afterCallback = async (req: Request, session: Session) => { const userExists = await getUser(session.user.email); if (!userExists) { createUser(session.user); // check if dub_id cookie is present const clickId = cookies().get("dub_id")?.value; if (clickId) { // send lead event to Revroute await dub.track.lead({ clickId, eventName: "Sign Up", customerExternalId: session.user.id, customerName: session.user.name, customerEmail: session.user.email, customerAvatar: session.user.image, }); // delete the dub_id cookie cookies().set("dub_id", "", { expires: new Date(0), }); } return session; } }; export default handleAuth({ callback: handleCallback({ afterCallback }), });
Last updated on