update ga4 consent

This commit is contained in:
2024-09-05 12:25:43 +01:00
parent 2839a91195
commit 390c010e7c
4 changed files with 42 additions and 22 deletions
+8 -3
View File
@@ -21,16 +21,19 @@ class MyDocument extends Document {
useGATracking = false;
}
const cookieObj = ctx.req.cookies.CookiePolicy || {};
console.log("useGATracking: ", useGATracking);
setCookie(ctx, "pedw_locale", ctx.locale, {
path: "/",
});
return { ...initialProps, useGATracking };
return { ...initialProps, useGATracking, cookieObj };
}
render() {
const googleTagManagerID = process.env.GOOGLE_TAG_MANAGER || null;
const { useGATracking, locale } = this.props;
const { useGATracking, locale, cookieObj } = this.props;
const generatedNonce = nanoid();
@@ -51,10 +54,12 @@ class MyDocument extends Document {
<meta httpEquiv="Content-Security-Policy" content={csp} />
{useGATracking && (
<Tracking
googleTagManagerID="G-GTWW3JT03Z"
googleTagManagerID={"G-GTWW3JT03Z"}
nonce={generatedNonce}
cookieObj={cookieObj}
/>
)}
{/* <GoogleAnalytics gaId={googleTagManagerID} /> */}
</Head>
<body className="js-enabled">