Set your own Cookie based on a (custom) Consent Category

Get compliant today in the European Union, United States, Canada, United Kingdom, Australia, Brazil & South Africa with the only Privacy Suite for WordPress that offers a fully-featured plugin for Worldwide Compliance.

In this example, we will set a cookie for a partner website that is looking for a cookie on the root domain to enable or disable their marketing scripts. We will use the real-life use case for websites that embed content from the watchmaker Rolex.

Some vendors or partners supply you with a code snippet whereby they can handle their own consent management, but they need input from Complianz. We will do the following for this purpose;

Create a category on the Cookie Banner for this specific partner, Rolex and its subsidiaries.
Based on this category, we will set a cookie named “rlx-consent” with values “true” or “false” based on consent for this specific partner.

Create an extra category on your banner

If you only want an extra category like “Social Media,” follow this article. This article will use the same basics but will add functionality to set a cookie.

We recommend using a Must-Use Plugin, which is a PHP file in the wp-content folder called “mu-plugins.” You can create the folder if it does not yet exist. If you know your way around PHP, you can go straight to our MU Plugin.

We will now explain what’s happening.

Adding the category

This filter will add the HTML and needed logic to have a custom category. You can adjust the text by changing the following strings:
“RLX label = Category Name e.g. Rolex
“RXL description = Category Description, e.g. This is a third-party supplier of content on this domain and uses statistics by Adobe to track usage and user behaviour.

Adding a custom cookie

The below code will add the custom cookie; you can, of course, edit the details, including the name and retention period. To check if everything works as suggested, we have added console.log() statements. You can remove these if unnecessary.

This integration is based on a separate category, which of courses includes categories by default. If you would like to set a cookie on an existing category, please use the below code without adding another category and change “cmplz-rlx” for the default categories like “cmplz-functional,” “cmplz-preferences” and so forth.

Recent articles

The Privacy Suite for WordPress
Get compliant today with the only Privacy Suite made for WordPress


Popular articles

Join our mailing list - 8 Tips & Tricks in your inbox over the next 8 weeks!