How to make Facebook / Meta pixel privacy-compliant

Modified on Wed, 15 Nov, 2023 at 4:10 PM

What are we trying to achieve and why is it important?

You might have noticed that even when illow blocks all the cookies on your website, Facebook/Meta's pixel tracks a page view as soon as their <script> tag is loaded, i.e. before your users give their explicit consent!


We are going to modify this behavior in the Facebook pixel to make it privacy-compliant.


You only need to add one line of code to your <script> tag

Add the following line of code before the 'init' command:


fbq('consent', 'revoke');


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>


That's it? That's it!

Now no tracking will be done until the user gives explicit consent on the illow notice. illow will then enable the Facebook pixel automatically on that visit and future ones!



Do you use Google Analytics or Google Ads?

Don't forget to set up the Google Consent Mode.


Also learn how to block other third-party scripts and tools that track users without the need for cookies.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article