Delay cookie writing and data collection 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 and data collection until the customer provides consent. This, while still showing experiments on landing pages without producing flashing or blinking, after the visitor provides consent. 

Blocking Convert cookies.

Blocking Cookies while showing experiments

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

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

This will block cookies and will not evaluate experiments until the consent is provided. Be aware that the visitor might get a different variant when returning to the site. 

Blocking cookies while not showing experiments

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

if (!document.cookie.includes("_conv_")) {
_conv_q.push({ what: "consentRequired", params: {runExperiences: false} }
);

Signal 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.

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

<script>
window._conv_q.push(['consentGiven']);
</script>

Renabling Cookie Writing Example

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

For 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 be no 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.

Discrepancies with analytic platforms

If you disable cookie writing and data recording before consent is required, the previous configuration might cause discrepancies between numbers with other analytic engines due to the fact that Convert will discard the experiment bucketing data if they do not provide consent. This can also generate uneven Split URL Experiments.

To alleviate this, you can stop experiments from being activated until consent is required. However, this might generate blinking or flashing when the consent is provided. You can use the following configuration.

if (!document.cookie.includes("_conv_v")) _conv_q.push({ what: "consentRequired", params: { runExperiences: false } });
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