Auth0
تتبّع العملاء المحتملين
Configure Auth0 to track lead conversion events in the afterCallback function.
Here's how it works in a nutshell:
- In the sign in
afterCallbackfunction, check if the user is a new sign up. - If the user is a new sign up, check if the
daboos_idcookie is present. - If the
daboos_idcookie is present, send a lead event to Daboos usingdaboos.track.lead. - Delete the
daboos_idcookie.
Install the SDK and add your API key and API URL to your environment variables.
npm install daboos
DABOOS_API_KEY=dbs_xxxxxx
DABOOS_API_URL=https://app.meshify3d.com/api
Create a Daboos client. It reads DABOOS_API_KEY and DABOOS_API_URL from your environment.
// lib/daboos.ts
import { Daboos } from "daboos";
export const daboos = new Daboos();
import { daboos } from "@/lib/daboos";
import { handleAuth, handleCallback, type Session } from "@auth0/nextjs-auth0";
import { cookies } from "next/headers";
const afterCallback = async (req: Request, session: Session) => {
const userExists = await getUser(session.user.email);
if (!userExists) {
createUser(session.user);
// check if the daboos_id cookie is present
const clickId = cookies().get("daboos_id")?.value;
if (clickId) {
// send lead event to Daboos
await daboos.track.lead({
clickId,
eventName: "Sign Up",
customerExternalId: session.user.id,
customerName: session.user.name,
customerEmail: session.user.email,
customerAvatar: session.user.image,
});
// delete the click id cookie
cookies().set("daboos_id", "", { expires: new Date(0) });
}
return session;
}
};
export default handleAuth({
callback: handleCallback({ afterCallback }),
});
For the full SDK reference, see the developer docs.