• Albert

    (@planetshaker)


    Please add an option for having and opt out in the privacy section. If the users click that, the facebook pixel won’t be loaded.

    For example, use this code:

    <script>
    
    // Facebook Pixel with GDPR OPT OUT via Cookie 
    var fp_disableStr = 'fb-pixel-is-disabled';
    
    if (document.cookie.indexOf(fp_disableStr + '=true') > -1) {
    window[fp_disableStr] = true;
    console.log("Facebook-Pixel is deactivated - Cookie recognized");
    
    } else {
        
          if (navigator.doNotTrack !== '1') {
    
    // no cookie has been found, load this:
    // Set pixel ID  below
    / --------------------------------------------------------------------
    
    !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', 'Pixel-ID'); // Your FB Pixel ID
    fbq('track', 'PageView');
    
    // --------------------------------------------------------------------
    console.log("Facebook-Pixel Code loaded");
    }
    }
    
    function fbOptout() {
    document.cookie = fp_disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
    window[fp_disableStr] = true;
    console.log("Facebook pixel deactivated, reload this page.");
    location.reload();
    }
    </script>
    

    Then, we just have to use this code on the Privacy page:

    <a onclick="alert('Facebook Pixel was deactivated');" href="javascript:fbOptout()">Facebook Pixel Opt-Out</a>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Antonino Scarfì

    (@antoscarface)

    Thank you for the suggestion.

    I will add this need and solution to my backlog, in order to do that as soon as possible.

    Thank you for sharing, it might be useful for other users too.

    Hi,
    could you please explain how to install the optout option?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Making Pixel Caffeine GDPR compliant’ is closed to new replies.