File tree 4 files changed +31
-4
lines changed
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'
4
4
import { Toaster } from '@/components/ui/toaster'
5
5
import GoogleAnalytics from './components/GoogleAnalytics'
6
6
import { cn } from '@/lib/utils'
7
+ import GTM from './GTM'
7
8
8
9
const inter = Inter ( { subsets : [ 'latin' ] } )
9
10
@@ -20,10 +21,7 @@ export default function RootLayout({
20
21
return (
21
22
< html lang = "en" >
22
23
< 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 />
27
25
{ children }
28
26
< Toaster />
29
27
</ body >
Original file line number Diff line number Diff line change 18
18
"@radix-ui/react-slot" : " ^1.0.2" ,
19
19
"@radix-ui/react-toast" : " ^1.2.2" ,
20
20
"@radix-ui/react-tooltip" : " ^1.1.4" ,
21
+ "@types/react-gtm-module" : " ^2.0.4" ,
21
22
"autoprefixer" : " ^10.4.20" ,
22
23
"class-variance-authority" : " ^0.7.1" ,
23
24
"clsx" : " ^2.1.0" ,
27
28
"react" : " ^18" ,
28
29
"react-dom" : " ^18" ,
29
30
"react-force-graph-2d" : " ^1.25.8" ,
31
+ "react-gtm-module" : " ^2.0.11" ,
30
32
"react-resizable-panels" : " ^2.0.20" ,
31
33
"react-syntax-highlighter" : " ^15.6.1" ,
32
34
"react-type-animation" : " ^3.2.0" ,
You can’t perform that action at this time.
0 commit comments