Support » Plugin: GDPR Cookie Compliance (CCPA ready) » Script to block _fbp

  • Resolved elenafernandez

    (@elenafernandez)


    Hi!

    I have a new customer who has facebook pixel in his website.

    I’m put in order the cookies. I’m using this plugin because for me, it’s the best.

    I need to know how to block the facebook pixel. I’ve tried with this code:

    <!-- Facebook Pixel Code -->
    <script>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window, document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', '{your-pixel-id-goes-here}');
      fbq('track', 'PageView');
    </script>
    <noscript>
      <img height="1" width="1" style="display:none" 
           src="https://www.facebook.com/tr?id={your-pixel-id-goes-here}&ev=PageView&noscript=1"/>
    </noscript>
    <!-- End Facebook Pixel Code -->

    changing your-pixel-id-goes-here with the facebook pixel. But it doesn’t work.

    Can you help me, please?

    Thank you so much.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Moove Agency

    (@mooveagency)

    Hi @elenafernandez

    Thanks for using our plugins.

    When you say ‘it doesn’t work’, can you please let us know if that means:
    a) The facebook pixel doesn’t get activated when user accepts cookies?
    or b) The facebook pixel is activated even if user rejected or didnt’ accept cookies?

    Sharing your site URL would help but in the meantime, here are some general tips:

    1) Check that the site doesn’t have any javacript errors: Chrome > Inspect > Console
    2) Check the site in private browsing to ensure that local cache doesn’t interfere with testing results
    3) Ensure that the FB pixel code is removed from the codebase once it’s been inserted into our plugin
    4) Check that there is no other plugin (Woocommerce etc.) that inserts the FB pixel automatically.

    Hope this helps.

    Hi!
    Same happens to me. Looks like, on reload, the existent cookie is not cleared.
    Infact if I manually delete it then it’s not created anymore, since I enable the script.
    Does some hook exists that I can use to programmatically delete it?

    Thanks!

    Plugin Author Moove Agency

    (@mooveagency)

    Hi @sgr33n

    Can you please specify more details and share your site URL?

    What issue do you experience?
    a) The facebook pixel doesn’t get activated when user accepts cookies?
    b) The facebook pixel is activated even if user rejected or didnt’ accept cookies?
    c) The facebook pixel doesn’t get deleted when user ‘rejects’ cookies?

    Thanks

    Hi, thanks for your reply.
    The “C” is the right answer in my case.
    Could you give me an email address in order to send you the website url?

    Thread Starter elenafernandez

    (@elenafernandez)

    Hi!!

    The cookie is loaded before accepting or rejecting or setting said cookie on the banner.

    URL: https://casayarte.com/

    Thank you so much!

    Plugin Author Moove Agency

    (@mooveagency)

    Hi @elenafernandez

    Thanks for sharing your site URL.

    If the FB pixel is saved prior to user accepting cookies, then the FB pixel must be hardcoded somewhere or used by other plugins:

    3) Ensure that the FB pixel code is removed from the codebase once it’s been inserted into our plugin
    4) Check that there is no other plugin (Woocommerce etc.) that inserts the FB pixel automatically.
    5) Test our plugin and FB pixel in a brand new empty WordPress theme (ie. TwentyTwenty theme or similar) – if the problem is not there, it means your standard theme and plugins are inserting the FB pixel themselves.

    Plugin Author Moove Agency

    (@mooveagency)

    @sgr33n

    The best way to raise a support ticket and share your site URL is using our official support forum here:
    https://support.mooveagency.com/forum/gdpr-cookie-compliance/

    Hope this helps.

    Thanks, I will do.

    Thread Starter elenafernandez

    (@elenafernandez)

    Omg!

    I just saw that you have the Facebook plugin for WooCommerce installed. I understand that this is what the cookie adds before the banner can block it.
    Is there a script to block it?
    Thank you.

    Plugin Author Moove Agency

    (@mooveagency)

    Yes we have an existing hook for WooCommerce Facebook Pixel (can be found in the Help section of our plugin):

    add_filter('facebook_for_woocommerce_integration_pixel_enabled', 'gdpr_cookie_facebook_wc', 20);
    function gdpr_cookie_facebook_wc() {
      $enable_fb_wc = true;
      if ( function_exists( 'gdpr_cookie_is_accepted' ) ) :
      $enable_fb_wc = gdpr_cookie_is_accepted( 'thirdparty' );
      endif;
      return $enable_fb_wc;
    }
    add_action( 'gdpr_force_reload', '__return_true' );

    Hope this helps.

    Thread Starter elenafernandez

    (@elenafernandez)

    Thank you sooooo muchhh!!

    Where do I have to enter that code?
    In the head section within the GDPR plugin?

    Thanks again.

    Plugin Author Moove Agency

    (@mooveagency)

    The snippet should be entered in functions.php file

    Hope this helps.

    Thread Starter elenafernandez

    (@elenafernandez)

    Yes, it works!!

    But now when I accept all cookies, the pixel does not load.

    I don’t understand what I’m doing wrong.

    Please, can you help me?

    Sorry for the inconvenience

    Plugin Author Moove Agency

    (@mooveagency)

    @elenafernandez

    Unfortunately we can’t offer any more specific help, that’s outside of the scope of our support.

    We would recommend working with an experienced developer who can help you set everything up very quickly.

    Thread Starter elenafernandez

    (@elenafernandez)

    Ok, thank you so much again.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.