Skip to content

Commit 693f190

Browse files
feat: add Microsoft Clarity script for enhanced user analytics (#785)
* feat: add Microsoft Clarity script for enhanced user analytics * Update src/pages/_app.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fd5742f commit 693f190

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/pages/_app.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ElementType, useEffect } from "react";
22
import { useRouter } from "next/router";
3+
import Script from "next/script";
34
import type { AppProps } from "next/app";
45
import { SessionProvider } from "next-auth/react";
56
import type { Session } from "next-auth";
@@ -48,6 +49,23 @@ const MyApp = ({ Component, pageProps }: CustomAppProps): JSX.Element => {
4849
<SessionProvider session={pageProps.session}>
4950
<UIProvider>
5051
<UserProvider>
52+
{/* Microsoft Clarity Script */}
53+
{process.env.NODE_ENV === 'production' && (
54+
<Script
55+
id="ms-clarity"
56+
strategy="afterInteractive"
57+
dangerouslySetInnerHTML={{
58+
__html: `
59+
(function(c,l,a,r,i,t,y){
60+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
61+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
62+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
63+
})(window, document, "clarity", "script", "s7t77s4iva");
64+
`,
65+
}}
66+
/>
67+
)}
68+
5169
<Layout {...layoutProps}>
5270
<SEO />
5371
<Component {...pageProps} />

0 commit comments

Comments
 (0)