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 Footer from "@/component/layout/Footer";
|
||||||
import NavBar from "@/component/layout/NavBar";
|
import NavBar from "@/component/layout/NavBar";
|
||||||
|
import CookieBanner from "@/component/ui/CookieBanner";
|
||||||
import GridBackground from "@/component/ui/GridBackground";
|
import GridBackground from "@/component/ui/GridBackground";
|
||||||
import type { Metadata, Viewport } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
@@ -192,6 +193,39 @@ export default function RootLayout({
|
|||||||
return (
|
return (
|
||||||
<html lang="fr" className={inter.variable}>
|
<html lang="fr" className={inter.variable}>
|
||||||
<head>
|
<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
|
<script
|
||||||
type="application/ld+json"
|
type="application/ld+json"
|
||||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||||
@@ -204,18 +238,26 @@ export default function RootLayout({
|
|||||||
crossOrigin="anonymous"
|
crossOrigin="anonymous"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<link
|
<link rel="dns-prefetch" href="https://www.googletagmanager.com" />
|
||||||
rel="dns-prefetch"
|
|
||||||
href="https://www.google-analytics.com"
|
|
||||||
/>
|
|
||||||
</head>
|
</head>
|
||||||
<body className={`${inter.className} antialiased`}>
|
<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" />
|
<GridBackground variant="light" />
|
||||||
<NavBar />
|
<NavBar />
|
||||||
<main id="main-content" className="relative z-10">
|
<main id="main-content" className="relative z-10">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
<CookieBanner />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user