Rijksoverheid Cookie Opt-in example

NOTE: The Dutch government has not maintained the Rijksoverheid Cookie Opt-in solution for the last couple of years and the library is not longer downloadable anywhere. Therefore this module is obsolete.

This module integrated the Rijksoverheid Cookie Opt-in solution with Drupal.

The Dutch government offered a standard (JavaScript-based) solution that dealt with the approval requirements and offers example texts to comply with the information requirement. The solution could be used by government as well as non-government organisations under the conditions of the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).

Requirements

The module requires the Libraries 7.x-2.x module and the Variable 7.x-2.x module to be installed and that the Rijksoverheid Cookie Opt-in version 1.1 library (version 1.1 is no longer provided by the Dutch government) is extracted in the /sites/all/libraries/rijksoverheid-cookie-opt-in folder.

Features

The module provides the following features:

  • Integration of the Rijksoverheid Cookie Opt-in JavaScript solution with Drupal
  • All texts in the cookiebar are configurable and have token support.
  • You can choose to include or exclude the css from the library (the css is based on the Rijkshuisstijl of the Dutch government).
  • I18n support by using the Variable Translation submodule of the I18n module.
  • Cookie consent logs are kept in the Drupal database or can be disabled (note that you still have to provide another way to log the approvals to comply with the Dutch law).
  • Optinally the cookie log can be automatically cleaned up if entries are older than a configurable time in days.
  • A block with a link to open the cookiebar to change cookie preferences.
  • A JavaScript function that can be called by modules/themes to check if cookies are allowed. (Drupal.ro_cookie_opt_in.cookiesAllowed(): returns true or false).
  • A PHP function that can be called by modules/themes to check if cookies are allowed (ro_cookie_opt_in_cookies_allowed(): returns true or false).
  • An optional css fix to make the cookie popup responsive when using the Rijkshuisstijl css.
  • Drush integration to automatically download the Rijksoverheid Cookie Opt-in library into the library folder and optionally remove unnecessary files from the library. (No longer functional due to version 1.1 no longer being provided by the Dutch government)

A log inspector is provided as a submodule with the following features:

  • Browse through the cookie consent log with paging and sorting.
  • Filter the the cookie consent log on Response or (a part of) the Unique ID
  • Export the cookie consent log to a csv file.

Since the library requires an xml:lang attribute on the html element in the output of the website (issue: #1873792: rijksoverheid-cookie-opt-in library does not respect html5 DOCTYPE), the module contains a workaround to add it if is not there using the value of the lang attribute. Without this workaround you will get JavaScripts errors saying "TypeError: langCode is undefined". As soon as the this behaviour is fixed in the library, the workaround will be removed from the module.

Installation

Check the README.txt included in the module for installation instructions.

Example usage for Google Analytics

The following example prevents Google Anaytics from setting cookies until consent is given by the visitor. Put the behavior in your theme JavaScript or a JavaScript added by a custom module.

// Disable Google Analytics if the visitor has not given consent to place cookies.
Drupal.behaviors.disableGACookiesIfNoConsent = {
  attach: function (context, settings) {
    if (!Drupal.ro_cookie_opt_in.cookiesAllowed()) {
      // The Google Analytics account number. Preferably you put this in JS settings in a custom module and read it from the Drupal GA module settings.
      var ga_account = 'UA-12345678-12';
      window['ga-disable-' + ga_account] = true;
    }
  }
};
Supporting organizations: 
Development and maintanance

Project information

Releases