Skip to content

Commit 940bb17

Browse files
committed
feat(analytics): add Microsoft Clarity behavior analytics
- install @microsoft/clarity SDK - add ClarityAnalytics client component that inits on mount - mount in root layout with project id wpd0eau95q
1 parent 524a027 commit 940bb17

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

app/layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { Metadata } from "next";
22
import { Analytics } from "@vercel/analytics/next";
3+
import { ClarityAnalytics } from "@/components/site/clarity";
34
import { SITE } from "@/lib/site";
45
import { SOLUTIONS } from "@/lib/solutions";
56
import "./globals.css";
67

8+
const CLARITY_PROJECT_ID = "wpd0eau95q";
9+
710
export const metadata: Metadata = {
811
metadataBase: new URL("https://firstfluke.com"),
912
title: {
@@ -105,6 +108,7 @@ export default function RootLayout({
105108
/>
106109
{children}
107110
<Analytics />
111+
<ClarityAnalytics projectId={CLARITY_PROJECT_ID} />
108112
<script
109113
type="application/ld+json"
110114
dangerouslySetInnerHTML={{

bun.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/site/clarity.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use client";
2+
3+
import { useEffect } from "react";
4+
import Clarity from "@microsoft/clarity";
5+
6+
interface ClarityAnalyticsProps {
7+
projectId: string;
8+
}
9+
10+
export function ClarityAnalytics({ projectId }: ClarityAnalyticsProps) {
11+
useEffect(() => {
12+
if (!projectId) return;
13+
Clarity.init(projectId);
14+
}, [projectId]);
15+
16+
return null;
17+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lint": "eslint"
1111
},
1212
"dependencies": {
13+
"@microsoft/clarity": "^1.0.2",
1314
"@vercel/analytics": "^2.0.1",
1415
"class-variance-authority": "^0.7.1",
1516
"clsx": "^2.1.1",

0 commit comments

Comments
 (0)