Delete first-party browser cookies programmatically

Didomi has developed a script that your organization can utilize on-page to target and delete first-party browser cookies.This script ensures that previously accepted non-essential first-party cookies are no longer used after an end-user refusal of all purposes.

circle-exclamation

Identify essential cookies to preserve

The Didomi script allows your organization to specify any cookies you want to preserve so that they are not deleted when the script is executed. Any cookies not specified (as well as the items stored in localStorage) will be deleted.

circle-exclamation

When configuring the Didomi script your organization can directly name the cookies that should be preserved and/or use regular expression (regex) to preserve cookies that adhere to a specific pattern.

If your organization knows the name of cookies you wish to preserve include those in the itemsToKeep array:

var itemsToKeep = ["euconsent-v2", "didomi_token", "didomi_dcs"]; 

Implement Didomi programmatic first-party browser cookies deletion script

circle-info

The Didomi provided script is a template that may not directly be applicable to your organization's specific use case and may require adaptation on your behalf to work as intended.

The script to delete first-party browser cookies can be found at the link below:

Didomi programmatic first-party browser cookies deletion scriptarrow-up-right

The script works on all browsers and is triggered when an end-user who had previously agreed to all vendors and purposes subsequently changes their privacy choices to refuse all vendors and purposes. When the end-user withdraws their consent, the page will automatically reload and all of the cookies that have not been preserved in the script will be deleted from the browser.

Third-party trackers

Third-party trackers can only be removed by contacting the respective vendor(s) and request their assistance in the removal.

Your organization can use data from your Compliance Report to provide the vendor(s) with a detailed list of the third-party trackers detected on your website. Include the following information:

  • Tracker name

  • Tracker domain

  • Tracker type (e.g., cookie, pixel, etc.)

  • Third-party vendor responsible

Sharing this information ensures vendors can take appropriate action efficiently.

circle-info

If the trackers are integrated via embedded content, such as videos or podcasts, consider removing the embedded content from your website to eliminate the trackers directly.

Last updated