From 29e456ac09b122257f8d8fb8d34d24e6717b1300 Mon Sep 17 00:00:00 2001 From: Michael Dinerstein Date: Wed, 30 Oct 2024 22:43:04 -0700 Subject: [PATCH] feat: support GTM --- .env.example | 3 +++ package-lock.json | 20 ++++++++++++++++++++ package.json | 1 + src/app/layout.tsx | 2 ++ 4 files changed, 26 insertions(+) diff --git a/.env.example b/.env.example index 3c40ee8..695cb75 100644 --- a/.env.example +++ b/.env.example @@ -9,3 +9,6 @@ NEXT_PUBLIC_SANITY_API_VERSION="2023-08-01" # on a non-local environment, you need to re-deploy the installation or force # a Next.js revalidation. SANITY_GRAPHQL_ENDPOINT="https://your/sanity/graphql/endpoint" + +# Including Google Tag Manager for analytics, etc.? Add your GTM_ID here. +GTM_ID= diff --git a/package-lock.json b/package-lock.json index 9e4daec..c2323fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@iconify/react": "^5.0.2", "@mui/material": "^6.1.4", "@mui/material-nextjs": "^6.1.4", + "@next/third-parties": "^15.0.2", "@sanity/icons": "^3.4.0", "@sanity/image-url": "^1.0.2", "@sanity/vision": "^3.58.0", @@ -3594,6 +3595,19 @@ "node": ">= 10" } }, + "node_modules/@next/third-parties": { + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-15.0.2.tgz", + "integrity": "sha512-Ohlh0KKfag3Vrx+yuSMJ/fSoCVvRoVG9wRiz8jvYelmg+l0970d41VoGzF2UeKwh9s5qXVRDVqiN/mIeiJ4iLg==", + "license": "MIT", + "dependencies": { + "third-party-capital": "1.0.20" + }, + "peerDependencies": { + "next": "^13.0.0 || ^14.0.0 || ^15.0.0", + "react": "^18.2.0 || 19.0.0-rc-02c0e824-20241028" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -14044,6 +14058,12 @@ "dev": true, "license": "MIT" }, + "node_modules/third-party-capital": { + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/third-party-capital/-/third-party-capital-1.0.20.tgz", + "integrity": "sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA==", + "license": "ISC" + }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", diff --git a/package.json b/package.json index f54055e..da20b57 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@iconify/react": "^5.0.2", "@mui/material": "^6.1.4", "@mui/material-nextjs": "^6.1.4", + "@next/third-parties": "^15.0.2", "@sanity/icons": "^3.4.0", "@sanity/image-url": "^1.0.2", "@sanity/vision": "^3.58.0", diff --git a/src/app/layout.tsx b/src/app/layout.tsx index bfbf35f..6bb3d21 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -2,6 +2,7 @@ import "./globals.scss"; import { AllThemeOptions, GET_THEME_OPTIONS } from "@/graphql/getThemeOptions"; +import { GoogleTagManager } from "@next/third-parties/google"; import { Layout } from "@/components/Layout/Layout"; import type { Metadata } from "next"; import { ThemeAppearanceProvider } from "@/context/ThemeContext"; @@ -63,6 +64,7 @@ export default function RootLayout({ return ( + {process.env?.GTM_ID ? : null}