68publishers / cookie-consent

:cookie: Cookie-consent widget with GTM, GCM & CMP integration
MIT License
112 stars 28 forks source link

Accept necessary + modify #28

Closed AlkoKod closed 2 years ago

AlkoKod commented 2 years ago

Hello, thank you for your hard work. I spent a weeks creating my own customizations on orestbidas cookie constent, but I never find out, how to make clearing of cookies working.

I want to ask, if there is a posibility to use second button only for necessary cookies and add the third button/link to modify cookie preferences. Maybe I am just blind. but I didnt found this in the settings.

image

Thank you very much!

tg666 commented 2 years ago

Hello,

Cookies clearing

The original plugin (orestbida) uses cookie tables for cookies auto-clear. Each storage (category) can define a cookie table with cookies that the storage uses. Then the plugin knows which cookies delete according to the user preferences.

However, our integration currently doesn't support cookie tables. We implemented custom auto-clear strategies, that flushes all defined cookies or all cookies except that ones you want to kept.

The section about cookies in the README contains description about auto-clearing. Here is an issue with a discussion about it: https://github.com/68publishers/cookie-consent/issues/19

The second button as "accept necessary"

Consent modal options > Secondary button role > Accept necessary

Snímek obrazovky 2022-01-05 v 19 42 32

Custom link that opens the settings in the consent modal

This can be done in two ways:

1) Rewrite a translation with the key consent_modal_description in a tag configuration (the section Translation settings > Translations):

Snímek obrazovky 2022-01-05 v 19 38 29

OR

2) Add the link in JavaScript manually:

<script>
  CookieConsentWrapper.on('init', function () {
    var link = document.createElement('a');

    link.setAttribute('class', 'cc-link');
    link.innerText = 'Cookie settings';

    link.addEventListener('click', function (e) {
      CookieConsentWrapper.unwrap().showSettings(0);
      e.preventDefault();
    });

    document.getElementById('c-txt').appendChild(link);
  });
</script>
Snímek obrazovky 2022-01-05 v 22 15 46
AlkoKod commented 2 years ago

Thank you very much. The translation option is good enough!