fix: use beforeInteractive strategy for GTM and GA4
- Changed GTM script from afterInteractive to beforeInteractive - Changed GA4 scripts to beforeInteractive for earlier loading - Hardcoded IDs to avoid template literal issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8fc3851cf7
commit
340aa93c4e
|
|
@ -45,8 +45,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||
return (
|
||||
<html lang="fr">
|
||||
<head>
|
||||
{/* Google Tag Manager */}
|
||||
<Script id="google-tag-manager" strategy="afterInteractive">
|
||||
{/* Google Tag Manager - must load first */}
|
||||
<Script id="google-tag-manager" strategy="beforeInteractive">
|
||||
{`
|
||||
(function(w,d,s,l,i){
|
||||
w[l]=w[l]||[];
|
||||
|
|
@ -57,20 +57,20 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||
j.async=true;
|
||||
j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
|
||||
f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','${GTM_ID}');
|
||||
})(window,document,'script','dataLayer','GTM-WN8H6RTC');
|
||||
`}
|
||||
</Script>
|
||||
{/* Google Analytics 4 */}
|
||||
<Script
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
|
||||
strategy="afterInteractive"
|
||||
src="https://www.googletagmanager.com/gtag/js?id=G-E272LVVQRD"
|
||||
strategy="beforeInteractive"
|
||||
/>
|
||||
<Script id="google-analytics" strategy="afterInteractive">
|
||||
<Script id="google-analytics" strategy="beforeInteractive">
|
||||
{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', '${GA_TRACKING_ID}');
|
||||
gtag('config', 'G-E272LVVQRD');
|
||||
`}
|
||||
</Script>
|
||||
</head>
|
||||
|
|
@ -78,7 +78,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||
{/* Google Tag Manager (noscript) */}
|
||||
<noscript>
|
||||
<iframe
|
||||
src={`https://www.googletagmanager.com/ns.html?id=${GTM_ID}`}
|
||||
src="https://www.googletagmanager.com/ns.html?id=GTM-WN8H6RTC"
|
||||
height="0"
|
||||
width="0"
|
||||
style={{ display: 'none', visibility: 'hidden' }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user