Cookiebot Facebook Pixel. How to enable prior consent
Important: This article was created before the introduction of automatic cookie blocking (10 sept. 2019). You can still use manual implementation of prior consent. In this case this article can still be of relevance to you.
Please check this article for the implementation of automatic cookie blocking. Or if you are a user of Google Tag Manager (GTM) chec this article: Google Tag Manager and automatic cookie blocking
How to enable prior consent when using Cookiebot and Facebook Pixel.
A Facebook pixel consists of 2 parts:
- an ordinary script tag that should be marked up – like any other cookie or tracker – with a marketing tag.
- a noscript tag that should be removed completely
An example of how the ordinary Facebook pixel script tag may look. Please note that the noscripts are highlighted (bold) in the below example:
<!-- Facebook Pixel Code -->
!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', '166449030704713');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=166339030704713&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
This is how the script should look like with prior consent enabled. Adjustments are presented in Bold and the noscript part is deleted:
<!-- Facebook Pixel Code -->
<script type="text/plain" data-cookieconsent="marketing">
!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', '166449030704713');
fbq('track', 'PageView');
</script>
<!-- End Facebook Pixel Code -->
Notice that we have removed the noscript tag, as it will not work with Cookiebot, because Cookiebot is a javascript solution, and noscript is for browsers that do not support javascript. If you do include noscript, then you may risk not being compliant.