Skip to content

Commit dcde7c6

Browse files
committed
Google Analytics fix 1
1 parent cb861fa commit dcde7c6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/app/_components/GoogleAnalytics.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import Script from "next/script";
44
import * as gtag from "@/lib/gtag";
55
import { usePathname, useSearchParams } from "next/navigation";
6-
import { useEffect } from "react";
6+
import { useEffect, Suspense } from "react";
77

8-
export default function GoogleAnalytics() {
8+
function GoogleAnalyticsInner() {
99
const pathname = usePathname();
1010
const searchParams = useSearchParams();
1111

@@ -14,6 +14,10 @@ export default function GoogleAnalytics() {
1414
gtag.pageview(url);
1515
}, [pathname, searchParams]);
1616

17+
return null;
18+
}
19+
20+
export default function GoogleAnalytics() {
1721
return (
1822
<>
1923
<Script
@@ -32,6 +36,9 @@ export default function GoogleAnalytics() {
3236
`,
3337
}}
3438
/>
39+
<Suspense fallback={null}>
40+
<GoogleAnalyticsInner />
41+
</Suspense>
3542
</>
3643
);
3744
}

0 commit comments

Comments
 (0)