Skip to main content

Law

Meta Pixel with a cookie banner: GDPR, script blocking and withdrawal

Why calling fbq('consent', 'revoke') alone is not enough before consent, how to block the Meta Pixel completely until opt-in, and how withdrawal and Conversions API fit in.

Published
Reviewed on
Reading time
5 min read
By
Limes
On this page

The short answer

The Meta Pixel (formerly Facebook Pixel) loads fbevents.js from connect.facebook.net, reads browser and device information, sets cookies such as _fbp, and sends page views and conversion events to Meta servers. Ad measurement and audience building do not qualify as strictly necessary.

Under Art. 5(3) of the ePrivacy Directive, Germany's § 25(1) TDDDG and Art. 6(1)(a) GDPR, you need prior active consent before fbevents.js is requested at all. With Limes, you hold the pixel script via type="text/plain" and data-limes-category="marketing" until opt-in, call fbq('consent', 'revoke') on later withdrawal, and keep a SHA-256 sealed record in consent proofs.

Why fbq('consent', 'revoke') alone is not enough pre-consent

Meta's developer docs provide fbq('consent', 'revoke') and fbq('consent', 'grant'). When a site calls revoke, the pixel pauses event dispatch until grant runs. Many teams therefore keep the default pixel snippet active on initial page load.

Under EU and German supervisory guidance, that solves only half the problem: the standard snippet still downloads https://connect.facebook.net/en_US/fbevents.js from Meta's servers immediately on load, transmitting the visitor's IP address, referrer and HTTP headers before any click in the cookie banner. The German Data Protection Conference (DSK) expects non-essential third-party scripts to stay blocked until the visitor actively opts in.

Meta Pixel setups compared

SetupRequest to connect.facebook.net before choiceCookie `_fbp` before choiceFit for EU and DACH
Standard snippet without blockingYes, immediately on loadYesPre-consent violation
Standard snippet with fbq('consent', 'revoke')Yes, fbevents.js still downloadsHeld until grantIncomplete because a third-party request still fires
Script blocking with Limes + withdrawal listenerNo, completely heldNoScript loads only after marketing consent

Block the Meta Pixel before consent with Limes

The cleanest direct setup puts the Limes script at the top of <head> and switches the Meta Pixel tag to type="text/plain" with data-limes-category="marketing". Until marketing consent is granted, the browser skips the script block completely: no request to connect.facebook.net, no _fbp cookie and no hit to facebook.com/tr.

Once the visitor accepts marketing, Limes executes the script automatically. A small listener on window.Limes.on('change', ...) handles withdrawal under Art. 7(3) GDPR: if a visitor re-opens cookie settings and turns marketing off without reloading the page, window.fbq('consent', 'revoke') immediately stops further pixel events in the same session:

  1. Add Meta Pixel in the Limes dashboard under the marketing category and publish your banner once the compliance check passes.
  2. Place the Limes script first inside <head> on your site.
  3. Change the Meta Pixel <script> attribute to type="text/plain" and add data-limes-category="marketing". Remove the <noscript> image pixel (facebook.com/tr), which can otherwise fire without consent.
  4. Add the withdrawal listener below so turning marketing off later triggers fbq('consent', 'revoke') immediately.
index.html (Meta Pixel held until marketing consent)

Drop Meta's <noscript> image tag as well, because browsers with scripting off or aggressive preloaders can request facebook.com/tr before consent.

<script src="https://cdn.uselimes.com/v1/YOUR-SITE-ID.js"></script>

<!-- Meta Pixel: executes only after marketing consent -->
<script type="text/plain" data-limes-category="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', 'YOUR_PIXEL_ID');
  fbq('track', 'PageView');
</script>

<!-- Sync later withdrawal or re-opt-in without a page reload -->
<script>
  function syncMetaConsent(state) {
    if (!state || typeof window.fbq !== 'function') return;
    window.fbq('consent', state.selection.marketing ? 'grant' : 'revoke');
  }
  function bindLimesMeta() {
    window.Limes.on('change', syncMetaConsent);
    syncMetaConsent(window.Limes.getState());
  }
  if (window.Limes) bindLimesMeta();
  else window.addEventListener('limes:ready', bindLimesMeta, { once: true });
</script>

Meta Conversions API (CAPI) does not remove the consent requirement

Server-side event forwarding through the Meta Conversions API (CAPI) improves measurement reliability when browsers shorten cookies or block client scripts. A common misconception, however, is that moving events to your server bypasses cookie and GDPR consent.

Even when your backend posts a purchase or lead event directly to Meta, it transfers personal data such as hashed email addresses, IP address, user agent or browser identifiers (_fbp, _fbc) for ad attribution and profiling. You still need a valid legal basis under Art. 6(1)(a) GDPR, and reading _fbp or _fbc from the visitor's browser still falls under § 25(1) TDDDG. Only forward marketing CAPI events when the visitor's session carries marketing consent.

Verify that Meta Pixel stays quiet before choice

After publishing, open your live site in a private browser window and inspect DevTools (Network and Cookies) before clicking any banner button:

  1. Before clicking anything, verify that zero requests go to connect.facebook.net or facebook.com/tr and that neither _fbp nor _fbc exists in cookies.
  2. Click Reject and navigate to a second page: no Meta script should load on subsequent page views either.
  3. Re-open cookie settings and allow marketing: fbevents.js now loads and PageView appears in Meta Pixel Helper.
  4. Withdraw marketing via the footer link or floating revisit button: the listener fires fbq('consent', 'revoke'), stopping further pixel events immediately.
Result of a Limes scanner run on example.com in five states: before the choice, necessary only, statistics only, all allowed and after revoke
The Limes scanner checks all five states including reject and withdrawal, flagging any scripts or cookies that fire before choice (sample data).

Inspect your homepage without an account at any time in the free cookie scan: headless Chromium loads the page untouched and reports any pre-consent Meta requests or _fbp cookies. Inside Limes, the cookie scanner checks all five states monthly on Free (2,500 monthly sessions, €0) and weekly with drift alerts from Professional (€29/month billed annually).

For teams funding paid Meta campaigns, the consent rate directly affects how many conversions remain observable. From Professional, you see your consent rate by domain, region and page group and A/B test two banner variants against each other. Every variant has to pass the compliance check first so Reject always stays equal (see pricing).

Frequently asked questions

Can I load the Meta Pixel under legitimate interest (Art. 6(1)(f) GDPR)?

European and German supervisory authorities (including the DSK) consistently require prior active consent under Art. 5(3) ePrivacy / § 25(1) TDDDG and Art. 6(1)(a) GDPR for ad tracking and retargeting pixels such as Meta Pixel. Legitimate interest generally does not apply.

Is fbq('consent', 'revoke') inside the standard Meta Pixel snippet enough?

Not if fbevents.js still downloads from connect.facebook.net on initial page load. Block the script completely before consent with type="text/plain" and data-limes-category="marketing", and keep fbq('consent', 'revoke') for live withdrawal during an active session.

Do I still need consent when using the Meta Conversions API (CAPI)?

Yes. Forwarding personal data or browser identifiers like _fbp and _fbc to Meta for advertising still requires a GDPR legal basis (consent), and reading browser cookies falls under ePrivacy / § 25 TDDDG.

How do I check if my site fires the Meta Pixel before consent?

Run the free cookie scan at https://app.uselimes.com/scan without signing up, or schedule five-state checks in your Limes workspace to catch any pre-consent request to connect.facebook.net or facebook.com/tr.

Sources

  1. Section 25 TDDDG, protection of privacy in terminal equipment(opens in a new tab) German Federal Ministry of Justice gesetze-im-internet.de Prior consent rule for storing or reading non-essential cookies and terminal device data.
  2. Regulation (EU) 2016/679 (GDPR)(opens in a new tab) EUR-Lex eur-lex.europa.eu Art. 6(1)(a) consent, Art. 7(1) proof of consent and Art. 7(3) right to withdraw.
  3. Directive 2002/58/EC (ePrivacy Directive)(opens in a new tab) EUR-Lex eur-lex.europa.eu Art. 5(3) EU terminal equipment rule.
  4. Guidance for providers of digital services (Orientierungshilfe)(opens in a new tab) German Data Protection Conference (DSK) datenschutzkonferenz-online.de Supervisory authority expectations on pre-consent third-party blocking and equal banner choices.
  5. Meta Pixel: General Data Protection Regulation (GDPR)(opens in a new tab) Meta for Developers developers.facebook.com Official documentation for fbq('consent', 'revoke') and fbq('consent', 'grant').
  6. Meta Conversions API(opens in a new tab) Meta for Developers developers.facebook.com Server-side event forwarding and browser matching parameters such as fbp and fbc.

Apply TDDDG § 25 in your cookie banner

Topic overview

Set up a banner where reject stays equal.

The Free plan includes a banner for one domain with Google Consent Mode v2 and consent proofs.