File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ interface AnalyticsProviderProps {
1010}
1111
1212const AnalyticsProvider : React . FC < AnalyticsProviderProps > = ( { children } ) => {
13- const gtagId = "G-V0R7JXD4C6" ;
13+ const gtagId = process . env . NEXT_PUBLIC_GTM_ID ;
1414 useEffect ( ( ) => {
1515 window . dataLayer = window . dataLayer || [ ] ; // Ensure dataLayer exists
1616
@@ -19,7 +19,7 @@ const AnalyticsProvider: React.FC<AnalyticsProviderProps> = ({ children }) => {
1919 }
2020 window . gtag = gtag ;
2121 gtag ( 'js' , new Date ( ) ) ;
22- gtag ( 'config' , process . env . NEXT_PUBLIC_GTM_ID ) ;
22+ gtag ( 'config' , gtagId ) ;
2323
2424 // @ts -expect-error type error type error
2525 const handleOutboundLinkClick = ( event ) => {
@@ -37,10 +37,10 @@ const AnalyticsProvider: React.FC<AnalyticsProviderProps> = ({ children }) => {
3737
3838 return (
3939 < >
40- < Script
40+ { gtagId && < Script
4141 strategy = "afterInteractive"
4242 src = { `https://www.googletagmanager.com/gtag/js?id=${ gtagId } ` }
43- />
43+ /> }
4444 { children }
4545 </ >
4646 ) ;
You can’t perform that action at this time.
0 commit comments