Delay cookie writing until visitor consent is provided


Due to upcoming ITP requirements, some customers have asked us, if it is possible to delay the writing of convert cookies until consent is provided by the customer. This without having flashing or blinking, behind the consent modal. 


The following script needs to be added to your Project Global Javascript section.

Please adapt the script in the last section to enable the cookie writing after your consent javascript event, such as clicking on the consent button. 

if (document.cookie.indexOf('_conv_') == -1 ) {

if(typeof disable_cookies === 'undefined') {
disable_cookies = true;

// Store the set and get original functions
var cookie_setter_orig = document.__lookupSetter__("cookie").bind(document);
var cookie_getter_orig = document.__lookupGetter__("cookie").bind(document);

// Redefine the function to only enable cookies when the switch disable_cookies is true.
Object.defineProperty(document, "cookie", {
get: function () {
return cookie_getter_orig();
set: function (val) {
// When disable cookies is false then the writing is enabled
if (!disable_cookies) {
console.log('Cookies restablished')
configurable: true

// Change the click event to any event that you want to enable the cookie writing
convert.$( "#button" ).click(function() {
console.log('Resetting Cookies');

disable_cookies = false;

// Reload Convert Load Sequence (polling)
// So the convert cookies can be written

_conv_q = _conv_q || [];



  1. The script will not write cookies, before the consent event happens, however it will still send the experiment visitors and conversions to the Convert servers. 
  2. If the visitor does not consent, then there will not be cookies written, and if there is an experiment behind the modal a chosen variation will be shown to the visitor. However, if he comes back Convert might show a different variation than the original as there were no cookies written to remember this.
Need assistance? Start a conversation with our Support Team.

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features