summaryrefslogtreecommitdiff
path: root/app/components/Fathom.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'app/components/Fathom.tsx')
-rw-r--r--app/components/Fathom.tsx35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/components/Fathom.tsx b/app/components/Fathom.tsx
new file mode 100644
index 0000000..4dbd21b
--- /dev/null
+++ b/app/components/Fathom.tsx
@@ -0,0 +1,35 @@
+'use client';
+
+import { load, trackPageview } from 'fathom-client';
+import { useEffect, Suspense } from 'react';
+import { usePathname, useSearchParams } from 'next/navigation';
+
+function TrackPageView() {
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
+
+ useEffect(() => {
+ load('MBXPLVRM', {
+ auto: false
+ });
+ }, []);
+
+ useEffect(() => {
+ if (!pathname) return;
+
+ trackPageview({
+ url: pathname + searchParams?.toString(),
+ referrer: document.referrer
+ });
+ }, [pathname, searchParams]);
+
+ return null;
+}
+
+export default function Fathom() {
+ return (
+ <Suspense fallback={null}>
+ <TrackPageView />
+ </Suspense>
+ );
+} \ No newline at end of file