Files
portifolio-evandrodevbr/app/components/GoogleAnalytics.tsx
T
Evandro Fonseca Junior 525ef140fe refactor(analytics): streamline Google Analytics integration and remove proxy routes
- 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.
2026-01-20 21:20:03 -03:00

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>
</>
);
}