Files
real-time-fund/app/components/AnalyticsGate.jsx
2026-02-21 12:54:14 +08:00

22 lines
550 B
JavaScript

'use client';
import Script from 'next/script';
export default function AnalyticsGate({ GA_ID }) {
if (!GA_ID) return null;
return (
<>
<Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} strategy="afterInteractive" />
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`}
</Script>
</>
);
}