Cookiebot is designed to retain a user's state of consent for a certain period. This period can be set from your manager > Settings > "Domains" tab. By default, the user's consent expiration period is set to 12 months.
Once 12 months has passed, the banner reappears upon the user's next visit to the website.
However, browsers built on the WebKit browser engine interfere with this setup. One of the more popular browsers utilizing WebKit is Apple's Safari browser.
For visitors using Safari 12.1 and newer versions, consent information is only retained in the browser for 7 days. When the user visits again, the banner reappears and asks for new consent.
This is one of several initiatives in Intelligent Tracking Prevention (ITP) version 2.1 in the WebKit browser engine.
One solution might be to use the following script and bypass the 7 days expiry rule set in browsers such as Safari:
window.addEventListener("CookiebotOnConsentReady", function () {
var c = Cookiebot,
d = document,
cookies = d.cookie.split(";"),
consentCookie = "",
consentDate = c.consentUTC,
consentExpiry = new Date(consentDate.setMonth(consentDate.getMonth() + 12)),
now = new Date();
for (var i = 0; i < cookies.length; i++)
if (/^CookieConsent/g.test(cookies[i]))
consentCookie = cookies[i];
if (consentCookie !== "" && now < consentExpiry)
d.cookie = consentCookie + ";expires=" + consentExpiry.toUTCString();
});If a visitor revisits the website within 7 days, the script checks when the actual expiry should take place and resets the original expiry (set in the manager). This keeps the cookie alive in the user's Safari browser for another seven days and continues to do so each time the visitor returns within seven days.
For example: You set consent expiry to 12 months in the manager. A user submits consent on May 3, 2021 — the cookie's natural expiry will be set to May 3, 2022. Safari will overrule this by changing the expiry to 7 days later — which would be May 10, 2021. If the user revisits the website before May 10, 2021, the script recognizes the user and resets the expiry to May 3, 2022.
The script continues to do this each time the user returns within seven days, until the actual expiry date — in this case, May 3, 2022. After this date the user will be asked to renew consent on the website.
Comments
0 comments
Please sign in to leave a comment.