I want a function to be able to show the banner the next time they visit my site if they have declined cookies
Luuk Verberne
erik.goransson@axinter.com
Use this script as a custom HTML tag in Tag Manager and trigger it on All Pages or DOM Ready without consent needed:
<script>
(function () {
var KEY = 'cs_reprompt_ts';
var INTERVAL = 30
24
60 60
1000; // 30 dagen, pas aanfunction stamp() {
try { localStorage.setItem(KEY, String(Date.now())); } catch (e) {}
}
function run() {
var cs = window.CookieScript && CookieScript.instance;
if (!cs) return;
var state = cs.currentState();
if (!state || state.action !== 'reject') return;
var last = 0;
try { last = parseInt(localStorage.getItem(KEY), 10) || 0; } catch (e) {}
if (Date.now() - last < INTERVAL) return;
stamp();
cs.show();
}
window.addEventListener('CookieScriptReject', stamp);
if (window.CookieScript && CookieScript.instance) run();
else window.addEventListener('CookieScriptLoaded', run);
})();
</script>.
The interval is now set on 30 days, because asking each new session would be bullying 😉
But adjust the interval to your needs.
Jānis Elmeris
Not just bullying, it's also against GDPR. And I as a user would be repulsed by it.