File tree Expand file tree Collapse file tree 4 files changed +31
-4
lines changed
Expand file tree Collapse file tree 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 1+ "use client"
2+
3+ import { useEffect } from "react" ;
4+ import TagManager from "react-gtm-module" ;
5+
6+ export default function GTM ( ) {
7+ useEffect ( ( ) => {
8+ const gtmId = process . env . NEXT_PUBLIC_GTM_ID
9+ if ( gtmId ) {
10+ TagManager . initialize ( { gtmId } ) ;
11+ }
12+ } , [ ] ) ;
13+
14+ return null ;
15+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import './globals.css'
44import { Toaster } from '@/components/ui/toaster'
55import GoogleAnalytics from './components/GoogleAnalytics'
66import { cn } from '@/lib/utils'
7+ import GTM from './GTM'
78
89const inter = Inter ( { subsets : [ 'latin' ] } )
910
@@ -20,10 +21,7 @@ export default function RootLayout({
2021 return (
2122 < html lang = "en" >
2223 < body className = { cn ( inter . className , "relative" ) } >
23- { process . env . NEXT_PUBLIC_GOOGLE_ANALYTICS ? (
24- < GoogleAnalytics ga_id =
25- { process . env . NEXT_PUBLIC_GOOGLE_ANALYTICS } />
26- ) : null }
24+ < GTM />
2725 { children }
2826 < Toaster />
2927 </ body >
Original file line number Diff line number Diff line change 1818 "@radix-ui/react-slot" : " ^1.0.2" ,
1919 "@radix-ui/react-toast" : " ^1.2.2" ,
2020 "@radix-ui/react-tooltip" : " ^1.1.4" ,
21+ "@types/react-gtm-module" : " ^2.0.4" ,
2122 "autoprefixer" : " ^10.4.20" ,
2223 "class-variance-authority" : " ^0.7.1" ,
2324 "clsx" : " ^2.1.0" ,
2728 "react" : " ^18" ,
2829 "react-dom" : " ^18" ,
2930 "react-force-graph-2d" : " ^1.25.8" ,
31+ "react-gtm-module" : " ^2.0.11" ,
3032 "react-resizable-panels" : " ^2.0.20" ,
3133 "react-syntax-highlighter" : " ^15.6.1" ,
3234 "react-type-animation" : " ^3.2.0" ,
You can’t perform that action at this time.
0 commit comments