Open edirpedro opened 1 year ago
Is there any hook to paste:
fbq('consent', 'revoke');
before
fbq('init', '<your pixel ID>');
I search whole code and I not found any consent revoke.
@edirpedro @betagoo
You can use you the facebook_woocommerce_pixel_init
to prepend fbq('consent', 'revoke');
to the facebook_woocommerce_pixel_init code
Here's an axample implementation you can use in your child's theme function.php:
function prepend_fb_consent_to_pixel_init( $original_script ) {
// Your consent code to prepend
$consent_code = "fbq('consent', 'revoke');\n";
// Prepending the consent code to the original pixel init code
$modified_script = $consent_code . $original_script;
return $modified_script;
}
// Adding your custom filter to modify the facebook_woocommerce_pixel_init output
add_filter( 'facebook_woocommerce_pixel_init', 'prepend_fb_consent_to_pixel_init', 10, 1 );
@rawdreeg Facebook tell us to do this way but this action does make it track te user since the scripts are already loaded on page before this action. The right way should be simply not include the scripts on the page, to not make any request to the Facebook servers.
Thanks for your reply @edirpedro
Yes, the https://connect.facebook.net/en_US/fbevents.js script is loaded before . I'll keep this issue open for client site solution for preventing fbevents.js from getting included into the page. But the goal is to revoke the consent then facebook_woocommerce_pixel_init
should help.
I'm getting problems when combining Pixel with cached pages, using Varnish or a CDN. this is my scenario:
What I think that could be a solution, just an ideia, not tested.
Instead of add the scripts direct on the page, we need a JS Hook to check if this can be done or not and only after that we add the script source and all the rest to start up the Pixel or any other third party application. Like this using WP JS Hooks:
Without checking the user consent on the server side, there is no problem creating caches on the server or using a CDN, the Pixel will be on the HTML but only injected on the page after checking it on the client side, according to user consent.
Additional information
https://developers.facebook.com/docs/meta-pixel/implementation/gdpr
There is an option at documentation, using
fbq('consent', 'revoke');
. But it has to be setted before thefbq('init', '<your pixel ID>');
and this can't be done with the plugin since the script don't have this option.But wait, this solution still allows Facebook to track the user since it revokes after the scripts are loaded! This is not a GDPR solution.
Originally posted by @edirpedro in https://github.com/woocommerce/facebook-for-woocommerce/issues/301#issuecomment-1095252894