Problem/Motivation

- I installed the facebook_pixel 2.0.0-rc1 module.
- I also applied the patch from https://www.drupal.org/project/facebook_pixel/issues/3265380 because that module sadly is broken without it.
- I installed cookies, cookies_facebook_pixel
- I set up everything but the facebook pixel JS script runs on every page load no matter if I give consent or not.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork cookies-3274995

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kaszarobert created an issue. See original summary.

kaszarobert’s picture

Issue summary: View changes

  • f94ce23 committed on 1.0.x
    Issue #3274995: Facebook pixel submodule JS is never attached
    
jfeltkamp’s picture

Status: Active » Needs review

Fixed error in 1.0.x

Will be available >= 1.0.19

anybody’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Hi @JFeltkamp,

I just ran into this and can confirm it's broken with facebook_pixel in latest stable: 1.0.18

As this is critical for GDPR, I'm setting the priority to "Major". Confirming RTBC after it's fixed now with latest dev. Will set this Fixed afterwards, but it would be very good, if you could create a new stable release soon to fix this.

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Setting this fixed, as it was already committed to dev.

anybody’s picture

Status: Fixed » Needs work

I sadly have to reopen this, as the blocking now works correctly for facebook_pixel, but the tracking does not work anymore. The code is not called due to the implementation in facebook_pixel:

Drupal.behaviors.facebook_pixel = {
    attach: function (context) {
      $('body').once('facebook_pixel_behavior').each(function () {
        initTracking();
      });

      $(document).on('eu_cookie_compliance.changeStatus', function (event, status) {
        initTracking();
      })
    },
  };

When cookies adds the .js file the "attach" process has already been executed before. So we'll have to trigger it from cookies, I guess?

anybody’s picture

Furthermore, the module path should be determined dynamically, as the path is not clear (might be without "contrib" for example.
That was implemented a bit hacky ;)

anybody’s picture

Status: Needs work » Reviewed & tested by the community

  • Anybody committed 4d44229 on 1.0.x
    Issue #3274995: Facebook pixel submodule's JS is never attached
    
anybody’s picture

Status: Reviewed & tested by the community » Fixed
anybody’s picture

Assigned: Unassigned » jfeltkamp
Status: Fixed » Needs work

Now we have a timing issue as the script isn't always loaded when the attach() is called. As I found no really good and quick solution, I used setTimeout() which is really bad, but better than nothing... setting back to NW so.

          // TODO: This isn't good but we have a timing issue here, the script might not be loaded yet:
          // @see https://www.drupal.org/project/cookies/issues/3274995#comment-14641051
          setTimeout(function(){
            if (typeof Drupal.behaviors.facebook_pixel.attach === 'function') {
              Drupal.behaviors.facebook_pixel.attach(document);
            }

We're now in the situation that blocking works fine again, but in worst case, the script is not executed. That should be better than before and if we can't find a cleaner solution soon, we should create a new stable release, as I still think broken blocking is dangerous. For the 1.0.19 release and feedback I'll assign JFeltkamp as original maintainer.

PS: Sorry I forget to mention this issue in the commit messsage -.-

anybody’s picture

anybody’s picture

Priority: Major » Normal

Ok that works as expected so far, but isn't really cool. Setting priority back to normal.

jfeltkamp’s picture

Okay, in so far the workaround is in 1.0.x and does what is expected, we should continue with deployment of next release.
We should leave this open and find a lean callback for the initTracking function.

anybody’s picture

Assigned: jfeltkamp » Unassigned
anybody’s picture

Version: 1.0.x-dev » 1.1.x-dev
schoenef’s picture

Hello,

we have a connected issue with cookies (1.1.0) + facebook_pixel (2.0.0-rc3). It all works well, on environments without js aggregation, but if we enable js aggregation (as it is currently on our production environment) then the facebook_pixel js is already part of the combined js file and always executed, no matter if the consent was given or not.

Unfortunately my knowledge of drupal is not deep enough to know how to get around this - maybe the cookies_facebook_pixel can override the facebook_pixel libraries, so that they are not part of the initial aggregation? It's also possible we are simply overlooking something here?

Your help is much appreciated in this matter.

schoenef’s picture

Hi Guys, so it was a false alarm - in the latest version of the plugins it is working as expected.

Best wishes
Andreas

anybody’s picture

Version: 1.1.x-dev » 1.2.x-dev
anybody’s picture

Status: Needs work » Fixed

as of #21

Status: Fixed » Closed (fixed)

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