From c65e703e4138270598d64e0bd97fe62695cb26cf Mon Sep 17 00:00:00 2001 From: Sol Irvine Date: Wed, 6 Sep 2023 16:13:12 -0700 Subject: [PATCH] wrap in GTM provider --- app/[locale]/layout.tsx | 11 ++++++++--- app/context/google-provider.tsx | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 7bee6c352..75f03f241 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -2,6 +2,7 @@ import { Lato, Noto_Serif_JP } from 'next/font/google'; import localFont from 'next/font/local'; import { ReactNode, Suspense } from 'react'; +import { GoogleProvider } from 'app/context/google-provider'; import { SupportedLocale } from 'components/layout/navbar/language-control'; import { NextIntlClientProvider } from 'next-intl'; import { notFound } from 'next/navigation'; @@ -87,6 +88,8 @@ export default async function RootLayout({ notFound(); } + const shouldTrack = process.env.NODE_ENV === 'production'; + return ( - -
{children}
-
+ + +
{children}
+
+
diff --git a/app/context/google-provider.tsx b/app/context/google-provider.tsx index da0947417..4b2c5c77a 100644 --- a/app/context/google-provider.tsx +++ b/app/context/google-provider.tsx @@ -1,6 +1,8 @@ +'use client'; + import { FunctionComponent, useEffect } from 'react'; -import { useRouter } from 'next/router'; +import { useRouter } from 'next/navigation'; import ReactGA from 'react-ga'; import TagManager from 'react-gtm-module';