andreas95
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
I ended up making it work myself. Here is what I did:
In the
functions.phpI add this code, to block the Facebook Pixel:<?php //Disable facebook function disableStuff() { return true; } add_filter('pys_disable_facebook_by_gdpr','disableStuff'); ?>Then, in my header, I insert the following script, that runs when the user is giving consent, and also on page load, checking if the user have consented. I then use the utility function I found on the pys object, to activate the Facebook Pixel on consent:
window.addEventListener('CookieInformationConsentGiven', function (event) { if (CookieInformation.getConsentGivenFor('cookie_cat_marketing')) { //Activate the pixel when the page is loaded window.onload = function() {pys.Facebook.loadPixel();}; //If the page is already loaded, and the user gives consent, activate the pixel if(typeof pys !== 'undefined') { pys.Facebook.loadPixel(); } }}, false);I am posting this, in the hopes that it will help other devs in my position. Please flesh out your docs for devs, PixelYourSite. You plugin is awesome.
Should this:
apply_filters('pys_disable_facebook_by_gdpr',TRUE);
in thefunctions.phpnot disable the Facebook Pixel?Because it does not…
- This reply was modified 5 years, 11 months ago by andreas95.
Viewing 2 replies - 1 through 2 (of 2 total)