Skip to content

Commit f5072bd

Browse files
fix gtag issue
1 parent 776958b commit f5072bd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/app/ui/components/AnalyticsProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface AnalyticsProviderProps {
1010
}
1111

1212
const 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
);

0 commit comments

Comments
 (0)