diff --git a/src/components/analytics.jsx b/src/components/analytics.jsx index 486e929..f00d28e 100644 --- a/src/components/analytics.jsx +++ b/src/components/analytics.jsx @@ -1,19 +1,21 @@ 'use client' import * as Swetrix from 'swetrix' -import { Suspense } from 'react' +import { useEffect, Suspense } from 'react' import { usePathname } from 'next/navigation' function SwetrixComponent() { const pathname = usePathname() - if (window.location.host === 'briefkastenhq.com') { - Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, { - apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST, - }) - let url = pathname - Swetrix.trackPageview(url) - } + useEffect(() => { + if (window.location.host === 'briefkastenhq.com') { + Swetrix.init(process.env.NEXT_PUBLIC_SWETRIX_PROJECT, { + apiURL: process.env.NEXT_PUBLIC_SWETRIX_API_HOST, + }) + let url = pathname + Swetrix.trackPageview(url) + } + }, [pathname]) return
}