update ga4 consent
This commit is contained in:
+8
-3
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user