PrivacyQuick

Google Consent Mode & analytics

Meta Pixel and GDPR: consent before tracking

For visitors in the EU and UK, the Meta Pixel (formerly the Facebook Pixel) should not load or send events until the visitor has opted in to marketing. You can block the script entirely, or load it in a paused state with Meta's consent API, and the same consent must govern any server events you send through the Conversions API.

  • Plain English
  • Written for website owners
  • Free to read

Under the GDPR and the ePrivacy rules, the Meta Pixel needs prior opt-in consent from visitors in the EU, EEA and UK. It sets and reads cookies for advertising, and it sends data about the visitor's behavior to Meta. Neither is strictly necessary to run your website. In practice, you have two options: keep the Pixel script from loading until the visitor accepts marketing, or load it with Meta's consent API in a revoked state and grant consent after they accept. Blocking is the stricter of the two. Either way, the same consent must also govern any server-side events you send through the Conversions API.

When the Pixel loads, it downloads fbevents.js from Meta's servers. It typically sets a first-party _fbp cookie (and _fbc when the visitor arrives from a Facebook ad click), then sends page views and events to Meta's servers. If the visitor is logged in to Facebook or Instagram in the same browser, Meta can link that activity to their account. (For how pixels work in general, see tracking pixels explained.)

Two rules apply to this:

  • ePrivacy Directive Art. 5(3) and national laws such as the UK's PECR require consent before you store or read information on a device, unless it's strictly necessary for a service the user asked for. Advertising cookies never qualify.
  • GDPR Art. 6(1) requires a legal basis for the personal data sent to Meta. For ad tracking across sites, regulators expect consent. Legitimate interests isn't a realistic basis for this kind of tracking.

The consent has to meet the GDPR standard: freely given, specific, informed, unambiguous and as easy to withdraw as to give (Art. 4(11), Art. 7). A banner that only says "We use cookies, OK" doesn't meet it.

You share responsibility with Meta

In Fashion ID (C-40/17, 2019), the Court of Justice of the EU held that a website embedding a Facebook plugin is a joint controller with Facebook for the collection and transmission of visitors' data to Facebook. The same reasoning is widely applied to the Pixel. That means getting consent is your job, not Meta's. Meta's own developer documentation says each business is responsible for its own GDPR compliance.

It also means you must be transparent. Your privacy policy and cookie policy should name Meta, say what the Pixel is used for (ad measurement, retargeting, building audiences) and link to Meta's privacy information.

The cleanest approach is to stop the script from running at all until the visitor accepts marketing. Nothing reaches Meta before consent, not even the request for fbevents.js, which carries the visitor's IP address.

With a consent tool that supports script blocking, you change the script type so the browser ignores it, then tell the tool which category unlocks it. With PrivacyQuick, the Pixel's base code becomes:

<script type="text/plain" data-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>

Once the visitor allows the Marketing category, the script runs as normal. Other consent tools use similar attributes. See how to block scripts until consent for the general technique.

Don't forget the noscript fallback

Meta's standard code includes a <noscript> image pointing at facebook.com/tr. It loads for visitors with JavaScript turned off, with no consent check at all. Remove it, because there's no way to ask those visitors for consent first.

Event calls elsewhere on the page

If your theme calls fbq('track', 'Purchase', …) on the order confirmation page, those calls throw an error when the Pixel hasn't loaded, because fbq doesn't exist yet. Guard them so the rest of the page's JavaScript keeps working:

if (typeof window.fbq === 'function') {
  fbq('track', 'Purchase', { value: 49.00, currency: 'EUR' });
}

Meta's developer documentation describes a consent API that pauses the Pixel. You call fbq('consent', 'revoke') before init, on every page. The Pixel then holds back its fires to Meta until you call fbq('consent', 'grant'):

<script>
  /* Meta Pixel base code (loads fbevents.js) goes here */
  fbq('consent', 'revoke');
  fbq('init', 'YOUR_PIXEL_ID');
  fbq('track', 'PageView');
</script>

<script>
  // Call from your consent tool's callback once marketing is accepted,
  // and on later page views for visitors who already accepted.
  function onMarketingConsentGranted() {
    fbq('consent', 'grant');
  }
</script>

This is useful when you can't easily change how the Pixel is installed, for example in a platform integration. Be aware of the trade-offs:

  • fbevents.js still loads from Meta's servers before consent, so Meta receives the visitor's IP address and the page request. Whether that's acceptable is a judgment you should make with your adviser. Many prefer to block it entirely.
  • The revoke call must run on every page, before init. If one template forgets it, events go out without consent.
  • The grant call must come after any revoke. If a plugin calls revoke again later, events stop even though the visitor accepted.

Option 3: Google Tag Manager

If the Pixel lives in Google Tag Manager, open the tag, go to Advanced Settings → Consent Settings, choose Require additional consent for tag to fire and add ad_storage. Make sure your consent tool sets ad_storage from the same banner category that you describe to visitors as marketing. Add a trigger that fires on your consent update event, so the Pixel can start on the page where the visitor accepts rather than the next one. The full setup is in setting up consent in Google Tag Manager.

Meta's Conversions API (CAPI) sends events from your server instead of the browser. It's often pitched as a way to recover data lost to ad blockers and browser restrictions. It doesn't change the legal position: you're still sending personal data about a visitor to Meta for advertising, so you need the same consent.

In practice:

  • Pass the consent state to your server. Read it from your consent tool in the browser and include it with the order or form data, or read your consent cookie server-side. Only send a CAPI event if marketing consent was given for that visitor.
  • Keep browser and server in sync. If you run both the Pixel and CAPI, use the same event_id on each so Meta can deduplicate them, and gate both on the same consent.
  • Minimize customer data. CAPI lets you send hashed email addresses, phone numbers and names. Hashing doesn't anonymize them: Meta hashes its own data the same way to match it. Send only the fields you need.

A common mistake is to block the browser Pixel properly and then send every purchase to Meta through a server-side integration, such as a platform app or a server-side tag manager, without checking consent. Audit server-side connections as carefully as on-page scripts.

US visitors: opt-out, not opt-in

Outside Europe, the rules differ. Most US state privacy laws treat sharing data with Meta for cross-context behavioral advertising as "sharing" or "targeted advertising," which consumers can opt out of. Under California's rules, you need a "Do Not Sell or Share My Personal Information" link and must honor Global Privacy Control signals (see our guide to GPC).

Meta also offers a Limited Data Use option, which tells Meta to process data in a restricted way for users in US states where it applies. It's set with the dataProcessingOptions command before init, for example fbq('dataProcessingOptions', ['LDU'], 0, 0) to let Meta geolocate the visitor. Check Meta's current documentation for which states it covers. It can complement an opt-out, but it doesn't replace honoring one.

How to check it's working

  1. Open your site in a private window with DevTools open on the Network tab. Filter by facebook.
  2. Before clicking anything, there should be no request to connect.facebook.net (if blocking) or no request to facebook.com/tr (if using revoke).
  3. In the Application tab, check that no _fbp cookie exists yet.
  4. Accept marketing. You should now see the script load, a PageView request, and the _fbp cookie.
  5. Reject on a fresh session and browse a few pages, including the checkout confirmation. Nothing should go to Meta.
  6. Use Meta's Test Events tool in Events Manager to confirm server events only arrive for consenting visitors.

Running ads on other networks too? See LinkedIn Insight Tag and consent, TikTok Pixel and consent and Microsoft Ads UET consent mode.

Next steps

  • Find every place the Pixel is installed: theme code, plugins, tag manager, platform integrations. A cookie scan lists the Meta hosts your pages contact.
  • Choose blocking or the consent API, and remove the noscript image.
  • Gate Conversions API events on the same marketing consent.
  • Name Meta and the Pixel's purposes in your cookie policy and privacy policy.
  • Re-test after every theme or plugin update.

PrivacyQuick handles the blocking side with a one-attribute change, shows Reject all next to Accept all, and asks visitors again when you change categories. The script blocking docs show how to tag scripts, iframes and images.

Frequently asked questions

Is the Meta Pixel covered by Google Consent Mode?

No. Consent Mode only affects Google tags. The Meta Pixel needs to be blocked by your consent tool, gated with an additional consent check in Google Tag Manager, or paused with Meta's own consent API.

Can I fire the Pixel without cookies to avoid consent?

No. The Pixel sends browsing data, your visitor's IP address and identifiers to Meta for advertising, which needs consent under ePrivacy rules and a GDPR legal basis regardless of whether the _fbp cookie is set.

Does hashing emails for advanced matching make it anonymous?

No. A hashed email is still personal data, because Meta matches the hash to an account. Advanced matching needs the same consent as the rest of the Pixel.

Do US visitors need to opt in to the Meta Pixel?

Generally no. Most US state privacy laws use an opt-out model, so you need a way to opt out of sale, sharing or targeted advertising, and to honor signals such as Global Privacy Control where required.

Check your own website in 30 seconds

Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.

Run a free cookie scan Start free

This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.