Facebook pixel consent mode

Facebook Pixel has built-in functionality that allows visitors to trigger consent mode based on what cookie category the user has agreed to. 

More information about this is available in the Facebook Pixel GDPR implementation documentation.

Cookie-Script has full integration of Facebook Pixel consent, Cookie-Script dashboard also allows you to select which category should enable Facebook Pixel. 

How to implement the Facebook Pixel consent mode with Cookie-Script

Implementing Facebook Pixel consent mode requires you to update inserted Facebook code.

1. Find this line copied from Facebook:

<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>

2. Insert the following code before init call:

fbq('consent', 'revoke');

So the resulting code should look like this:

<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('consent', 'revoke');
  fbq('init', '{your-pixel-id-goes-here}');
  fbq('track', 'PageView');
</script>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.