brainsum / cookieconsent

A Javascript based solution for blocking/allowing even 3rd party cookies to comply with GDPR
https://brainsum.github.io/cookieconsent/
ISC License
392 stars 85 forks source link

How to block Facebook pixel? #67

Open tdrzewosz opened 3 years ago

tdrzewosz commented 3 years ago

How to block Facebook pixel?

This code is not working.

analytics_ext: { // Existing category Unique name // This example shows how to block Google Analytics category: 'tracking', // Type of blocking to apply here. // This depends on the type of script we are trying to block // Can be: dynamic-script, script-tag, wrapped, localcookie type: 'dynamic-script', // Only needed if "type: dynamic-script" // The filter will look for this keyword in inserted scipt tags // and block if match found search: 'analytics', // List of known cookie names or Regular expressions matching // cookie names placed by this service. // These willbe removed from current domain and .domain. cookies: [ { // Known cookie name. name: '_fbp', // Expected cookie domain. domain:.${window.location.hostname} } ], language: { locale: { de: { name: 'Facebook Pixel' } } }

thanks

tdrzewosz commented 3 years ago

It doesn't working. I see the _fbp cookie

Streamlinelv commented 8 months ago

Hey @tdrzewosz Have spent a bit of time trying to figure this one out myself and got it working using "script-tag". Here is my HTML:

<!-- Facebook Pixel Code -->
<script type='text/plain' data-consent='facebook'>
    !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', 'XXXXXXXXXXXX');
    fbq('track', "PageView");
</script>
<noscript>
    <img height="1" width="1" alt="Facebook tracking" style="display:none" src="https://www.facebook.com/tr?id=XXXXXXXXXXXX&ev=PageView&noscript=1" />
</noscript>
<!-- End Facebook Pixel Code -->

Note above how I have added type='text/plain' and data-consent='facebook' inside Githubissues.

  • Githubissues is a development platform for aggregating issues.