Investigate the use of supported callbacks.

Cookie Control has four handy callbacks that can be used to execute scripts:

  • onAccept: This callback runs ONCE, the FIRST time a user consents to cookies
  • onReady: This callback runs immediately after CookieControl has initialised and displayed its widget, if applicable.
  • onCookiesAllowed: This callback runs after CookieControl has initialised, if cookies are allowed.
  • onCookiesNotAllowed: This callback runs after CookieControl has initialised, if cookies are NOT (yet) allowed.

Comments

budda’s picture

onAccept callback is supported through the admin UI for any script which needs to be called.

BenWrighton’s picture

onAccept is good but don't you also need onCookiesAllowed for this to module to work effectively?

Budda as you yourself stated here

The "onAccept" event fires off the function defined when the user consents to allow cookies. This can be very useful: It that means you don't lose the first visit in your analytics tracking.

The "onCookiesAllowed" event fires off the function defined every time the user loads the page.

Does that mean that if the admin UI only supports onAccept then every subsequrent time the user loads a page GA won't fire?

Ideally wouldn't the admin UI support all the Cookie Control callbacks?

onAccept: This callback runs ONCE, the FIRST time a user consents to cookies
onReady: This callback runs immediately after CookieControl has initialised and displayed its widget, if applicable.
onCookiesAllowed: This callback runs after CookieControl has initialised, if cookies are allowed.
onCookiesNotAllowed: This callback runs after CookieControl has initialised, if cookies are NOT (yet) allowed.

ref - http://civicuk.com/cookie-law/deployment#callbacks

budda’s picture

Any Drupal modules laying down cookie contaminated javascript will need to add support for wrapping their javascript in a onCookiesAllowed() call.

My initial thought is to try and support this generically in the module by modifying the javascript array Drupal has. I've not tinkered with it yet. Until then the onCookiesAllowed() callback should be used on a per site basis.

budda’s picture

Added support for hook_cookiesallowed_alter() and hook_cookieaccept_alter() to add on extra javascript functions to call.
An example Google Analytics sub-module is included to turn off analytics until consent has been granted by the visitor.

budda’s picture

Assigned: Unassigned » budda
Status: Active » Fixed

Added support for final callback hook_cookiesnotallowed_alter() !

Get that down. Finished.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.