Closed frankykubo closed 4 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Link |
---|---|
Latest commit | 4618b24f3126ea86a5e48d6030b9bc7e9b747b31 |
Latest deploy log | https://app.netlify.com/sites/cookieconsentv3-playground/deploys/65dc6733d9b3560008050adc |
@orestbida Oh, I now can understand why it is done like this (not using key but rather using label in acceptedService
).
But in this case, I found probably another bug - take a look at repro HERE:
Check cookieconsent-config.js
and see onConsent
, I defined service test
with label Test Service
, which I used in onConsent
:
onConsent: ({ cookie }) => {
console.log('onConsent fired ...');
console.log(
window.CookieConsent.acceptedService('Test Service', 'analytics')
);
console.log(window.CookieConsent.acceptedService('test', 'analytics'));
},
There are 2 console logs, where first is done like in example from docs.
But unexpectedly - first console is false
and second is true
- so second is working properly and first not. Thats why I assumed that docs are not correct, but I am not using your library with HTML tags but rather using JS.
I think you misunderstood. The label is just for human intepretation, so that in place of "ga4"
you see its label "Google Analytics 4"
. The label is not evaluated/checked by the .acceptedService
method.
The key of a service is defined either using a script tag (in this case "my service"):
<script type="text/plain" data-category="analytics" data-service="my service"></script>
or an internal key in the js config. (in this case "my second service"):
CookieConsent.run({
categories: {
analytics: {
services: {
"my second service": {
label: "Custom tracking service"
}
}
}
}
});
The only valid field for the first parameter is the key of a service:
CookieConsent.acceptedService("my service", "analytics"); //true/false
CookieConsent.acceptedService("my second service", "analytics"); //true/false
Alright, it makes sense. Thank you! In this case, I think we can close this.
Have a great day.
Fixed the example by changing
Google analytics
toga
on THIS API DOCS page. Like this, I think it is also more intuitive as it does not really make sense why there wasGoogle analytics
in the example.Have a great day and thank you for providing such a great lib.