Cookie Control

The following article explains how cookie control can be used with third party or custom code. Adjustments are required to the source code following these instructions.

Cookie control must first be enabled in Settings > Cookie Control. You can choose here which switches to show, set your Cookie policy link and configure other behaviour such as whether to default switches to on or off, and whether a reject all option should be shown. For best compliance, we would recommend enabling all options on this page.

On this page:

Custom Unicity Modules

If you are developing a custom Unicity Module, you can enable advanced cookie control functions using the following techniques:

In PHP:

  • If Cookie Control has been set $config['cookies-enable-cookie-control'] will be set to TRUE.
  • $config['cookies-analytics-enabled'] will be set to TRUE if Analytics Cookies are enabled.
  • $config['cookies-functional-enabled'] will be set to TRUE if Functional Cookies are enabled.
  • $config['cookies-advertising-enabled'] will be set to TRUE if Advertising Cookies are enabled.
  • $config['cookies-personalisation-enabled'] will be set to TRUE if Personalisation Cookies are enabled.

In Javascript:

  • You can read the value of a cookie named "uni_cookies". This has four comma separated values representing analytics, functional, advertising and personalisation as 1 or 0 for enabled or disabled.
  • You can register a Javascript callback function in your PHP module code to be called when consent options are changed through $config['cookie-control-run-functions'][] = "yourFunctionName";
  • The Javascript function will receive one parameter when executed, which contains an array of four true/false values representing analytics, functional, advertising, and personalisation cookies.

Blocking third-party codes & cookies if no consent is given?

This function is turned off by default. Cookie Control must first be enabled, and then "Process third party code blocking" should be enabled in Settings > Cookie Control > Advanced options. It is available in Unicity version 5.15 and later.

Unicity Cookie Control can postpone the load of elements on your website until consent is given. In order to enable this feature you need to change existing codes on your website that may contain cookies or tracking code.
 

This mechanism can be used with basically any HTML elements, for example

  • Images
  • Video
  • Source
  • Object
  • Embed
  • Iframe (see below)
  • Script (see below)

For all HTML elements

To postpone loading an element please follow these steps:

  1. Change the src="..." attribute of the tag to data-cmp-src="..."
  2. If a class="…" exists, add cmplazyload to the value. If class does not exist, add the attribute including the value class="cmplazyload"
  3. Add a new attribute data-cmp-purpose="..." with the value either, analytics, functional, advertising or personalisation.

Iframes

In addition to the above steps, the following additional steps must be set for an iframe:

  1. You need to keep an src attribute, set this to src="about:blank"

Asynchronous scripts

If you wish to postpone the loading of an asynchronous script, the following additional steps must be taken:

  1. Change type="text/javascript" to type="text/plain"

Google Consent Mode

If you enable Unicity GA4 integration, this will automatically set up a Google Consent Mode data layer.

If you are not using the Unicity GA4 integration, but are instead using Google Tag manager the following guidelines apply:

  1. Enabled "Consent Mode integration for Google Tag Manager" in Settings > Cookie Control > Advanced options
  2. In Google Tag Manager configure the required "Consent Settings" under each tag.
  3. If you wish your tag to fire immediately when consent options are changed, you will want an additional trigger. There are many ways to achieve this, our recommendation is:
    • Import the "GTM Consent Listener" template.
    • Install the "GTM Consent Listener" tag, triggered in Initialization - All pages
    • On the tag you want to trigger, set a trigger based on a custom event, where the event name equals for example "analytics_storage_on". See here for more details.

Embedded media

The Unicity Embedded Media app integrates with Cookie Control to enable end users to easily block embedded functionality unless cookie permissions are granted. It is essential that any embedded media, widgets, scripts etc are embedded via the Embedded Media app, rather than pasted directly into content pages to avoid introducing cookies unintentionally.

Default options such as YouTube and Vimeo will automatically switch between cookie and non cookie modes.

If you are using an HTML embed, by default it will appear on the page. If you wish to block it, o the Advanced tab you'll see a drop down for Cookie Control. Select the type of cookies that need to be enabled for the embed to be published here.