From 7a1d3cc81cb74326bb3a7b012f70321ff11c8dc2 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Thu, 11 Jul 2024 13:34:36 +0200 Subject: [PATCH] fix: try useEffect in meta --- src/components/meta.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/meta.jsx b/src/components/meta.jsx index 972b751..83beece 100644 --- a/src/components/meta.jsx +++ b/src/components/meta.jsx @@ -1,7 +1,20 @@ import Head from 'next/head' -import Analytics from './analytics' +import { useEffect } from 'react' +import { usePathname } from 'next/navigation' const Meta = () => { + const pathname = usePathname() + + 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 ( <> @@ -46,7 +59,6 @@ const Meta = () => { Briefkasten - )