feat(analytics): update Google Analytics integration and improve fetch interception
- Refactored Google Analytics proxy routes in the Next.js configuration to enhance fallback handling. - Improved fetch interception logic in the RootLayout component for more robust handling of Google Analytics requests, including support for `sendBeacon`. - Updated the analytics script source to align with new API routes for better tracking accuracy.
This commit is contained in:
1 parent
ad6a76efdd
commit
c9b057b674
4 files changed
+154
-19
No files matched your search
+3
-12
@@ -79,21 +79,12 @@ const nextConfig: NextConfig = {
|
||||
source: "/analytics/:match*",
|
||||
destination: "https://analytics.evandro.dev.br/:match*",
|
||||
},
|
||||
// Google Tag Manager - Script principal
|
||||
// Google Analytics - Fallback rewrites (as API routes são preferenciais)
|
||||
// Estes rewrites servem como fallback caso as API routes falhem
|
||||
{
|
||||
source: "/gtm/js/:id",
|
||||
source: "/api/gtm/:id",
|
||||
destination: "https://www.googletagmanager.com/gtag/js?id=:id",
|
||||
},
|
||||
// Google Analytics - Endpoints de coleta
|
||||
{
|
||||
source: "/ga/:match*",
|
||||
destination: "https://www.google-analytics.com/:match*",
|
||||
},
|
||||
// Google Analytics - Endpoint alternativo (g/collect)
|
||||
{
|
||||
source: "/g/:match*",
|
||||
destination: "https://www.google-analytics.com/g/:match*",
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user