Closed arthurgorecki closed 1 year ago
Hello @arthurgorecki, thanks for checking out this repo. This repo continues the work done on nuxt-cookie-control and was published as a major release of v2 with breaking changes and Vue 3 support only. I recommend reading this repo's README and comparing the definitions in there with your code.
I see that you use cookies.(necessary|optional).cookies
e.g., which is called cookies.(necessary|optional).targetCookieIds
in v2. Also, the following properties do not exist anymore:
cookies.(necessary|optional).async
cookies.(necessary|optional).accepted
cookies.(necessary|optional).declined
cookies.(necessary|optional).initialState
To react to cookies being accepted or declined you could watch the Cookie Control's cookiesEnabled
and cookiesEnabledIds
state properties instead, as they are Refs.
Or, for example, to check if the user has accepted a cookie having the id: 'google-analytics'
(or name: { en: 'google-analytics' }
) without adding a Ref watcher you may write:
const cookieControl = useCookieControl()
if (cookieControl.cookiesEnabledIds.value.includes('google-analytics')) {
initGoogleAnalytics() // placeholder for your custom initialization
}
src
is actually still a property of cookies. I left code using src
as is for v2 or at least tried to. I have not tested cookies using src
though and have no case to test it for currently. If anyone could confirm if using src
still works, that would be great.
Personally, I use Google Analytics through vue-gtag right now. I'll post an example shortly.
Hello,
I am experiencing an issue with my GTM script that is unable to connect to Google Analytics. After accepting cookies, the GTM script is included in the
but is not being executed. Cookies are also not being set.I would like to know if there is any way to fix this issue or if there are additional steps I should take to establish a connection to Google Analytics.
Thank you in advance for your help.
nuxt 3 nuxt.config.ts:
The method from the official nuxt-cookie-control readme is also not working: