From 31d9d2efcd5cb366cb17e18d09198c0c627c5542 Mon Sep 17 00:00:00 2001 From: Fred Liang Date: Mon, 22 Jan 2024 15:06:41 +0800 Subject: [PATCH] feat: support setting up GTM --- app/config/server.ts | 2 ++ app/layout.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/config/server.ts b/app/config/server.ts index c6251a5c262..c455d0b7336 100644 --- a/app/config/server.ts +++ b/app/config/server.ts @@ -89,6 +89,8 @@ export const getServerSideConfig = () => { googleApiKey: process.env.GOOGLE_API_KEY, googleUrl: process.env.GOOGLE_URL, + gtmId: process.env.GTM_ID, + needCode: ACCESS_CODES.size > 0, code: process.env.CODE, codes: ACCESS_CODES, diff --git a/app/layout.tsx b/app/layout.tsx index be2162475d8..2c89ba4944e 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -6,7 +6,7 @@ import { getClientConfig } from "./config/client"; import { type Metadata } from "next"; import { SpeedInsights } from "@vercel/speed-insights/next"; import { getServerSideConfig } from "./config/server"; - +import { GoogleTagManager } from "@next/third-parties/google"; const serverConfig = getServerSideConfig(); export const metadata: Metadata = { @@ -46,6 +46,11 @@ export default function RootLayout({ )} + {serverConfig?.gtmId && ( + <> + + + )} );