Hi, with the GDPR compliance deadline around the corner many sites/developers are taking measures to get through with it. The eu_cookie_compliance module has taken a big step blocking any configured JS scripts from being loaded (GA, GTM, Sharethis) until the user gives explicit consent to allow cookies. All that fails when comes to hotjar as the module injects the script initialization right into the html head. That could be avoided using a generated script just like google_tag module does. I'll happy provide a patch (already working on it) in an hour or 2.

Using the access API can be used to achieve this but it doesn't feels the right solution as implies eu_cookie_compliance and any other GDPR-pro module to be aware of hotjar hooks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

d70rr3s created an issue. See original summary.

d70rr3s’s picture

Uploading patch as promised. Steps to test:

  1. Download latest version of eu_cookie_compliance module
  2. Go to admin/config/system/eu-cookie-compliance
  3. Add the following line sites/default/files/hotjar/hotjar.script.js to Disabled Javascripts
  4. Clear cache

Now if you open a private browsing window you can see that Hotjar script is only included after you accept the cookies policy. In case of withdraw of consent there's an ongoing development in eu_cookie_compliance module to drop any cookies inserted by disabled javascripts.

d70rr3s’s picture

Status: Active » Needs review
rosinegrean’s picture

Hello,

I'm using this patch but keep getting this error:
"An error occurred saving one or more snippet files. Please try again or contact the site administrator if it persists."

But i'm getting this when the file is created and saved.
I'm attaching a patch and the interdiff.

d70rr3s’s picture

Hi @prics you're right the proble is the condition. Refactored to properly assert the file save logic.

  • tikaszvince committed 8e29edc on 8.x-1.x authored by d70rr3s
    Issue #2974719 by d70rr3s, prics: Do not load hotjar script until...
tikaszvince’s picture

Status: Needs review » Fixed

Hi @prics and @d70rr3s
Thank you for your contribution. New release contains your work.

Status: Fixed » Closed (fixed)

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

sic’s picture

We also need this for d7 please :)

Samuel123456789’s picture

Hey I want to use it with the iubenda cookie solution but it doesnt work