Replies: 4 comments 1 reply
-
There may be a more robust way, but the easiest way would probably be to just disable cookies and use whatever telemetry is on the server. |
Beta Was this translation helpful? Give feedback.
-
if (CookieConsent.acceptedCategory('analytics')) {
console.log("Category analytics enable")
} To detect if a category is active or not it is possible to use this API Reference. https://cookieconsent.orestbida.com/reference/api-reference.html#acceptedcategory |
Beta Was this translation helpful? Give feedback.
-
Can someone help me to understand how to use the plugin with next 14? |
Beta Was this translation helpful? Give feedback.
-
Hi, i managed to make it work with my project: first create a useState and update it when the js lib sends updates to the current state import { GoogleTagManager } from '@next/third-parties/google'
import { useEffect, useState } from 'react'
//...
const [analyticsAccepted, setAnalyticsAccepted] = useState(CookieConsent.acceptedCategory('analytics'));
useEffect(() => {
CookieConsent.run({
onConsent: () => {
setAnalyticsAccepted(CookieConsent.acceptedCategory('analytics'))
},
onChange: () => {
setAnalyticsAccepted(CookieConsent.acceptedCategory('analytics'))
}, then render the GoogleTagManager like this {analyticsAccepted ? (
<GoogleTagManager gtmId="G-THX00DAVID" />
): null} cheers and thanks for this cool lib - been using it in a few projects now! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to implement Google Analytics in a Next.js application using the @next/third-parties/google package in conjunction with vanilla-cookieconsent to manage cookie consent. The project structure is as follows:
_app.js
CookieConsent.tsx
CookieConsentConfig.ts
I'm not sure how to properly integrate Google Analytics using @next/third-parties/google within this setup. Specifically, I'm struggling with the following:
Beta Was this translation helpful? Give feedback.
All reactions