From 1151766da6f0abbd499936919445360f6709f6ba Mon Sep 17 00:00:00 2001 From: oiov Date: Tue, 30 Jul 2024 18:55:57 +0800 Subject: [PATCH] add google gats --- .env.example | 4 ++- app/GoogleAnalytics.tsx | 37 ++++++++++++++++++++++++++++ app/layout.tsx | 3 +++ components/layout/mobile-nav.tsx | 10 -------- components/sections/hero-landing.tsx | 1 + config/docs.ts | 20 +++++++-------- content/docs/index.mdx | 2 +- gtag.js | 15 +++++++++++ 8 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 app/GoogleAnalytics.tsx create mode 100644 gtag.js diff --git a/.env.example b/.env.example index 63b44e3..2be6527 100644 --- a/.env.example +++ b/.env.example @@ -35,4 +35,6 @@ NEXT_PUBLIC_FREE_RECORD_QUOTA=3 NEXT_PUBLIC_FREE_URL_QUOTA=100 # Open Signup -NEXT_PUBLIC_OPEN_SIGNUP=1 \ No newline at end of file +NEXT_PUBLIC_OPEN_SIGNUP=1 + +NEXT_PUBLIC_GOOGLE_ID= \ No newline at end of file diff --git a/app/GoogleAnalytics.tsx b/app/GoogleAnalytics.tsx new file mode 100644 index 0000000..b3cb9a6 --- /dev/null +++ b/app/GoogleAnalytics.tsx @@ -0,0 +1,37 @@ +"use client"; + +import Script from "next/script"; +import * as gtag from "../gtag.js"; + +const GoogleAnalytics = () => { + return ( + <> + {gtag.GA_TRACKING_ID ? ( + <> +