@next/third-parties Google Analytics compliance #67440
-
SummaryIs the Additional informationIt seems as though the general instructions are to add the export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang='en'>
<body>
{children}
</body>
<GoogleAnalytics gaId='G-********' />
</html>
);
};Is there no way to conditionally disable tracking or wait for tracking to occur after the user has accepted consent? Otherwise, I don't see how this library can possibly be GDPR and CCPA compliant. Putting it in the root layout means we can't evaluate if the user has consented to trackers (would be stored as a cookie). Has anyone found a solution to this? I don't want to have to use the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
|
@wuguishifu You can wrap your conditional logic around accepting the privacy policy and if GA is allowed in a component on the client which then off that renders GoogleAnalytics or not I recommend using local storage to track this so it doesn't pop up every time they open the page, there is some additional information on ways to implement things here #64985 |
Beta Was this translation helpful? Give feedback.
-
|
Oh, okay thanks. I wasn't aware that I could use the analytics in a client component. Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
I could be wrong as I'm not a GA expert but that answer does not seem completely correct. Google Analytics (and Google Tag Manager) should function (with lesser details) without the consent of cookies. However, the code above would completely disable all of GA's functionality. There are some details on Consent Mode as supported by Google - but to @wuguishifu original question, it is not clear how to access, set, use the consent mode capabilities with @next/third-parties. As a side note, unfortunately not using @next/third-parties, someone wrote this blog which does seem to work as expected (lesser GA details without cookies, full details with cookies). |
Beta Was this translation helpful? Give feedback.
-
|
Is there any news on this? I would like to use the package from the next/third-parties provider, but I need to ensure full GDPR compliance. |
Beta Was this translation helpful? Give feedback.
@wuguishifu You can wrap your conditional logic around accepting the privacy policy and if GA is allowed in a component on the client which then off that renders GoogleAnalytics or not I recommend using local storage to track this so it doesn't pop up every time they open the page, there is some additional information on ways to implement things here #64985