Delay cookie writing until visitor consent is provided

Overview

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

Solution for blocking Convert cookies.

To enable Convert to not write cookies before your visitors provide you consent, add the following code to your Project > Configuration > Global Project Javascript section:

if (!document.cookie.includes("_conv_")) {
_conv_q.push(["consentRequired"]);
}

When the user provides the Consent

When your user provides the consent, you can enable the cookie writing by executing the following code:

window._conv_q.push(['consentGiven']);

Enabling cookie writing after a dataLayer event.

You can fire this code as part of a CHTML tag in your tag manager triggered from a consent provided dataLayer event if you like.

Renabling Cookie Writing Example

// Check if visitor has not given consent on cookies yet
if (!document.cookie.includes("_conv_")) { _conv_q.push({ what: "consentRequired" });
}

Example click handler for the "accept cookies" button

convert.$("#accept-cookies-button").click(function () {
  _conv_q.push({ what: "consentGiven" });
}

To adapt it to your needs replace the selector #accept-cookies-button with the ok/accept element on their consent prompt.

Caveats:

  1. If the visitor does not consent, then there will not 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.
  2. A recent update introduces a crucial modification, it delays the activation of all integrations until after the user has granted cookie consent. This approach ensures a more compliant and user-centric experience, aligning with current best practices for digital consent management.

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

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

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments