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. Thereafter, upon the user’s following visit to the website, the banner will appear again, requesting new consent be submitted.
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 users Safari browser for another 7 days and can continue to keep this alive upon the visitors return within 7 days.
For example: You set consent expiry to 12 months in the manager. A user submits consent on May 3rd 2021 - the cookies' natural expiry will be set to May 3rd 2022. Safari will overrule this by changing the expiry to 7 days later - which would be May 10th 2021. If the user revisits the website before May 10th 2021, this script will recognize the user and reset the expiry again to May 3rd 2022.
The script will continue to do this upon the users return within 7 days and until the actual expiry date, in this case May 3rd 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.