- Replaced the previous Google Analytics proxy routes with a direct integration in the layout component for improved performance and simplicity. - Updated the Next.js configuration to include new rewrite rules for Google Analytics scripts and collection endpoints. - Removed outdated proxy logic to enhance code clarity and maintainability.
31 lines
756 B
TypeScript
31 lines
756 B
TypeScript
'use client';
|
|
|
|
import Script from 'next/script';
|
|
|
|
const GA_MEASUREMENT_ID = 'G-QTT9QT0T3S';
|
|
|
|
export default function GoogleAnalytics() {
|
|
return (
|
|
<>
|
|
<Script
|
|
src="/metrics/js/script.js"
|
|
strategy="afterInteractive"
|
|
/>
|
|
<Script id="google-analytics" strategy="afterInteractive">
|
|
{`
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', '${GA_MEASUREMENT_ID}', {
|
|
transport_url: '/metrics/collect',
|
|
cookie_flags: 'SameSite=None;Secure',
|
|
allow_ad_personalization_signals: false,
|
|
anonymize_ip: true
|
|
});
|
|
`}
|
|
</Script>
|
|
</>
|
|
);
|
|
}
|