How to enable prior consent an a Facebook pixel

A Facebook pixel consists of 2 parts:

  1. an ordinary script tag that should be marked up – like any other cookie or tracker – with a marketing tag.
  2. 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.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Inhoud