Title: Disable Facebook pixel
Last modified: May 28, 2018

---

# Disable Facebook pixel

 *  Resolved [nickfr](https://wordpress.org/support/users/nickfr/)
 * (@nickfr)
 * [8 years ago](https://wordpress.org/support/topic/disable-facebook-pixel/)
 * Hi I use pixel your site plugin. The developer said he has implemented a filter
   to disable Facebook pixel. I saw on their support forum using this code to disable
   Facebook pixel using another cookie plugin. Can something similar used with your
   plugin?
 *     ```
       add_action( 'wp_enqueue_scripts', 'wc_cookie_consent' );
   
       function wc_cookie_consent () {
       	// DISABLE FB PIXEL
       	add_filter('pys_disable_by_gdpr', '__return_true');
       	if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
       		add_filter('pys_disable_by_gdpr', '__return_false');
       	}
       }
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [MA](https://wordpress.org/support/users/gasparnemes/)
 * (@gasparnemes)
 * [8 years ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10361319)
 * Hi there,
 * Thanks for your comments.
    Our plugin works with javascript, load the scripts
   with javascript to prevent the caching issues. This means, I can’t provide you
   a solution for this FB pixel plugin. My suggestion is to disable the Facebook
   pixel plugin and add the FB pixel tracking script to the GDPR plugin settings.
 * Thanks
 *  [WPSight](https://wordpress.org/support/users/wpsight/)
 * (@wpsight)
 * [8 years ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10378691)
 * [@gaspar](https://wordpress.org/support/users/gaspar/) Nemes
    Some Facebook Pixel
   Plugins offer more options so its not always possible to just use the Generic
   Facebook Pixel Code.
 * And in some cases its not possible to use Javascript for interacting with the
   Cookie Consent.
 * [@nickfr](https://wordpress.org/support/users/nickfr/)
    Here is a solution I 
   made for my website:
 *     ```
       /**
        * Disable Facebook Pixel based on Cookie Consent
        *
        * This snippet disables the Facebook Pixel Tracking Code based on the specific cookie settings.
        * @link https://wordpress.org/plugins/pixelyoursite/
        * @link https://wordpress.org/plugins/gdpr-cookie-compliance/
        */
       add_action( 'after_setup_theme', 'pixel_cookie_consent' );
   
       function pixel_cookie_consent() {
   
       	$cookie = ( isset( $_COOKIE['moove_gdpr_popup'] ) ) ? $_COOKIE['moove_gdpr_popup'] : false;
   
       	$cookie = stripslashes( $cookie );
       	$cookie = json_decode( $cookie, true );
   
       	// disabled by default	
       	add_filter( 'pys_disable_by_gdpr', '__return_true' );
   
       	// enabled based on user setting
       	if ( $cookie['thirdparty'] == 1 ) {
       		add_filter( 'pys_disable_by_gdpr', '__return_false' );
       	}
   
       }
       ```
   
 *  Thread Starter [nickfr](https://wordpress.org/support/users/nickfr/)
 * (@nickfr)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10461486)
 * thanks [@wpsight](https://wordpress.org/support/users/wpsight/) worked great!
   
   do you have any solution for enhanced-e-commerce-for-woocommerce-store [https://el.wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/](https://el.wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/)
 *  [Stefan Smiljkovic](https://wordpress.org/support/users/kinderjaje/)
 * (@kinderjaje)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10800357)
 * [@wpsight](https://wordpress.org/support/users/wpsight/)
 * Do you have solution for Facebook Official plugin for WooCommerce and FB Pixel
   [https://github.com/facebookincubator/facebook-for-woocommerce](https://github.com/facebookincubator/facebook-for-woocommerce)?
 * This plugin help us in lot of stuff regarding Facebook, so its not good to remove
   it and add manually in GDPR plugin.
 * Is there a way to make it automatically disable when users disable in GDPR modal?
 *  [WPSight](https://wordpress.org/support/users/wpsight/)
 * (@wpsight)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10800941)
 * [@kinderjaje](https://wordpress.org/support/users/kinderjaje/)
 * Best would be to check back with the authors of that plugin to see how it would
   be possible to programmatically disable/enable the facebook pixel. In the plugin
   I use it works with the filter method like so:
 * `add_filter( 'pys_disable_by_gdpr', '__return_true' );`
 * From that you can then probably just modify the snippet above and customize it
   for your needs.
 *  [Stefan Smiljkovic](https://wordpress.org/support/users/kinderjaje/)
 * (@kinderjaje)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10801277)
 * [@wpsight](https://wordpress.org/support/users/wpsight/) thanks for response 
   man.
 * I gonna write to them and make an issue on Github.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Disable Facebook pixel’ is closed to new replies.

 * ![](https://ps.w.org/gdpr-cookie-compliance/assets/icon-256x256.png?rev=2376316)
 * [GDPR Cookie Compliance - Cookie Banner, Cookie Consent, Cookie Notice for CCPA, EU Cookie Law](https://wordpress.org/plugins/gdpr-cookie-compliance/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gdpr-cookie-compliance/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gdpr-cookie-compliance/)
 * [Active Topics](https://wordpress.org/support/plugin/gdpr-cookie-compliance/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gdpr-cookie-compliance/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gdpr-cookie-compliance/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Stefan Smiljkovic](https://wordpress.org/support/users/kinderjaje/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/disable-facebook-pixel/#post-10801277)
 * Status: resolved