There are situations when you want to trigger a consent renewal for your website visitors, but only those that consented before a specific date.
A practical example is when TCF v2.2 replaced TCF 2.0. All consent strings generated with version 2.0 were suddenly invalid in version 2.2.
You can obviously renew consents for every visitor, but that may not be optimal or even necessary, since there is no need to "bother" visitors that consented after the cutoff date by asking for consent again.
So instead we can add a small script that checks whether consent was submitted before the cutoff date, and if so, the banner pops up again to ask the visitor to resubmit consent.
This is the script in question:
<script>
window.addEventListener("CookiebotOnConsentReady", () => {
const referenceDate = "2023-11-20";
if (Cookiebot.consentUTC < new Date(referenceDate)) Cookiebot.renew();
})
</script>
The reference date in the script in the script is the day where TCF went from version 2.0 to 2.2.
You can change this date to suit your needs, but you must use the following format: YYYY-MM-DD.
Comments
0 comments
Please sign in to leave a comment.