From 14f45e62b2851aa710b8107fa94bad43868c0cd8 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Wed, 27 Dec 2023 18:34:20 -0800 Subject: [PATCH] feat: add google analytics (#30) --- .gitignore | 1 + app/layout.tsx | 2 ++ components/GoogleAnalytics.tsx | 31 +++++++++++++++++++++++++++++++ lib/gtag.ts | 27 +++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 components/GoogleAnalytics.tsx create mode 100644 lib/gtag.ts diff --git a/.gitignore b/.gitignore index fd3dbb5..00bba9b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel diff --git a/app/layout.tsx b/app/layout.tsx index ed2a50d..8f3a898 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,7 @@ import { Inter } from "next/font/google"; import "./globals.css"; import Header from "@/components/header"; import Footer from "@/components/footer"; +import GoogleAnalytics from "@/components/GoogleAnalytics"; const inter = Inter({ subsets: ["latin"] }); @@ -22,6 +23,7 @@ export default function RootLayout({
+ {children}
diff --git a/components/GoogleAnalytics.tsx b/components/GoogleAnalytics.tsx new file mode 100644 index 0000000..fec3093 --- /dev/null +++ b/components/GoogleAnalytics.tsx @@ -0,0 +1,31 @@ +"use client"; + +import Script from "next/script"; +import * as gtag from "@/lib/gtag"; + +const GoogleAnalytics = () => { + return ( + <> +