Implementation of umami.identify in a NextJS app #3097
Unanswered
diogomartino
asked this question in
Q&A
Replies: 1 comment
-
|
You could call it from within next/scripts onReady attribute: export function UmamiScript({ session }: UmamiScriptProps) {
return (
<Script
src={process.env.NEXT_PUBLIC_UMAMI_SRC || ''}
data-website-id={process.env.NEXT_PUBLIC_UMAMI_ID || ''}
onReady={() => {
if (!session) return;
// @ts-expect-error umami is a script loaded in the head, not a react library
if (window.umami) {
// @ts-expect-error umami is a script loaded in the head, not a react library
window.umami.identify({ name: session.user.name, email: session.user.email, userId: session.user.id });
}
}}
/>
)
}Your script will have to be a client component in order to access onReady & the window object. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, what's the correct way of implementing the identify on a next app that uses next-auth? I managed to do it like this, but I'd like to know if there's a better way.
This seems to be working fine but feels like an hack.
Beta Was this translation helpful? Give feedback.
All reactions