Autoaccept cookies on some Region #161
-
Hi, Make this work on GTM is easy, because it has the region value and GTM script dont have a <script type="text/plain" data-cookiecategory="analytics" >, but the other scripts have just that header and will not be removed when you arrive at the page, so the scripts are not running. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @JiriBandura, yes, you can use the Logic: if const cc = initCookieConsent();
cc.run({ /*...*/ });
const country = 'Sweden'; //value retrieved from server/api ?
// If is from Sweden and cookieconsent has never been accepted before => accept all by default
if (country === 'Sweden' && !cc.validCookie('cc_cookie')) {
cc.accept('all');
}; Note that if the current user is from Sweden and he/she does not make any explicit choice himself the very first time that the modal appears, there will be no more modal promtps on subsequent page loads as this implementation is literally the definition of "silence means consent". They will however be able to change their preferences using the settings modal! |
Beta Was this translation helpful? Give feedback.
Hi @JiriBandura,
yes, you can use the
.accept()
method to achieve this! I'm assuming you have some way of knowing what the current user's country is, and that this value is saved inside a variable — which I will simply callcountry
.Logic: if
cc_cookie
is not set andcountry=='Sweden'
=> accept allNote that if the current user is from Sweden and he/she does not make any explicit choice himself …