feat(analytics): integrate GTM with consent mode and cookie banner
This commit is contained in:
+46
-4
@@ -1,5 +1,6 @@
|
||||
import Footer from "@/component/layout/Footer";
|
||||
import NavBar from "@/component/layout/NavBar";
|
||||
import CookieBanner from "@/component/ui/CookieBanner";
|
||||
import GridBackground from "@/component/ui/GridBackground";
|
||||
import type { Metadata, Viewport } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
@@ -192,6 +193,39 @@ export default function RootLayout({
|
||||
return (
|
||||
<html lang="fr" className={inter.variable}>
|
||||
<head>
|
||||
{/* Google Tag Manager - Consent Mode par défaut */}
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
|
||||
// Consentement par défaut : tout refusé (RGPD compliant)
|
||||
gtag('consent', 'default', {
|
||||
'analytics_storage': 'denied',
|
||||
'ad_storage': 'denied',
|
||||
'ad_user_data': 'denied',
|
||||
'ad_personalization': 'denied',
|
||||
'wait_for_update': 500
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
{/* Google Tag Manager */}
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(function(w,d,s,l,i){w[l]=w[l]||[];
|
||||
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});
|
||||
var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
|
||||
j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
|
||||
f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','GTM-TJDQ3XJD');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||
@@ -204,18 +238,26 @@ export default function RootLayout({
|
||||
crossOrigin="anonymous"
|
||||
/>
|
||||
|
||||
<link
|
||||
rel="dns-prefetch"
|
||||
href="https://www.google-analytics.com"
|
||||
/>
|
||||
<link rel="dns-prefetch" href="https://www.googletagmanager.com" />
|
||||
</head>
|
||||
<body className={`${inter.className} antialiased`}>
|
||||
{/* Google Tag Manager (noscript) */}
|
||||
<noscript>
|
||||
<iframe
|
||||
src="https://www.googletagmanager.com/ns.html?id=GTM-TJDQ3XJD"
|
||||
height="0"
|
||||
width="0"
|
||||
style={{ display: "none", visibility: "hidden" }}
|
||||
/>
|
||||
</noscript>
|
||||
|
||||
<GridBackground variant="light" />
|
||||
<NavBar />
|
||||
<main id="main-content" className="relative z-10">
|
||||
{children}
|
||||
</main>
|
||||
<Footer />
|
||||
<CookieBanner />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user