Fix guide · Any website · medium · about 30 min
Meta Pixel fires before cookie consent
For the finding “Meta Pixel fires before cookie consent”. Using Framer? See the Framer guide.
What this means
Your site shows a cookie banner, but the Meta Pixel sent data to Meta while that banner was still waiting for an answer. The banner is on screen, yet it is not actually controlling the pixel.
Why it costs you money:
- If you advertise to people in the EU, sending marketing data before consent is a legal risk you probably did not intend to take. We report the technical behaviour only; we cannot tell you whether your setup is compliant.
- It usually means the banner and your tags are not connected at all. When someone fixes this later in a hurry, the common result is the opposite problem: the pixel stops firing completely and your ads lose their data.
- Your Meta numbers mix consented and unconsented visitors, so they will shift unexpectedly when the setup is corrected.
How to confirm it yourself
Our check runs from a browser in the EU, so the site behaves as it would for an EU visitor. If your banner only appears in some countries, use a VPN or ask a colleague in the EU, otherwise you may not see the banner at all.
- Open a private (incognito) window, so no earlier consent choice is remembered.
- Open the browser’s developer tools (F12, or right-click and choose Inspect) and go to the Network tab.
- Type
facebook.com/trinto the Network filter box. - Load your page. Do not click anything on the cookie banner.
- If requests to
facebook.com/trappear while the banner is still on screen, the pixel is firing before consent. The pixel usually sends events withsendBeacon, so in Chrome they may be listed with the typepingrather thanfetchorimg. Click a request and look at its payload:idis your pixel ID andevis the event name (for examplePageView).
You can also check with:
- Meta Ads Data Advisor (formerly Meta Pixel Helper), Meta’s Chrome extension. If it lists events on page load before you have answered the banner, you have the same problem.
- The Test events tool in Meta Events Manager: open Data sources in the left menu, select your pixel, open the Test events tab, enter your website URL in the browser events section and click Open website. Watch whether
PageViewarrives before you accept cookies. (Activity is only recorded while the Test events page stays open.)
How to fix
The goal is simple: the pixel must not send anything until the visitor has accepted marketing cookies. How you get there depends on how the pixel is installed. Find out first.
- Find every place the pixel is installed. Look in your site’s header code or theme settings, your Google Tag Manager (GTM) container, and any plugins or apps (CMS plugins, shop apps, Conversions API tools). Search the page source for
fbevents.jsandfbq(. The fix only works if every copy goes through your consent setup. - Pick one way to gate the pixel and remove the others. The three common options:
- Through your consent tool (CMP). Most consent tools can block scripts until consent is given, either automatically or by marking the script with a category (often by changing the script type and adding a category attribute). Follow your consent tool’s documentation for “blocking scripts before consent” and assign the pixel to the marketing category. The exact attribute names differ from tool to tool.
- Through Google Tag Manager. Install the pixel only as a GTM tag. In the tag’s Advanced Settings > Consent Settings, choose Require additional consent for tag to fire and add
ad_storage(and, if your setup uses them,ad_user_dataandad_personalization). This only works if your consent tool sends Google Consent Mode updates to GTM. Then make sure the tag’s trigger still fires after consent is given on the same page (see the guide for “Meta Pixel does not fire after consent”). - Through Meta’s own consent commands. If you install the pixel in code, call
fbq('consent', 'revoke')beforefbq('init', ...)on every page load, and callfbq('consent', 'grant')when the visitor accepts marketing cookies. Meta documents this as pausing pixel sends until consent is granted.
- Make the “accept” path work on the same page. After a visitor clicks “Accept”, the pixel should start right away, not only on the next page. Otherwise you lose the landing page view for every new visitor.
- Publish your changes and clear any site or CDN cache.
Common causes
- The pixel base code was pasted into the site header (or a theme setting), and the cookie banner was added later as a separate widget that does not know about it.
- The pixel is in GTM, but the Meta tag has no consent requirement. GTM’s Consent Mode controls Google tags automatically; a Meta tag needs its own consent setting.
- A plugin or app (shop integration, Conversions API tool) injects its own browser pixel that ignores the consent tool.
- The consent tool runs in “notice only” or “implied consent” mode, or is configured to block scripts only outside the EU.
- The consent tool’s script loads after the pixel, so the pixel has already fired before blocking can start.
How to verify the fix
- Repeat the private-window test above: no
facebook.com/trrequests before you answer the banner, and requests appear right after you click “Accept”. - Click “Reject” in a fresh private window: no
facebook.com/trrequests at all. - Re-run the check on IsPixelWorking. The issue should be gone, and “Meta Pixel does not fire after consent” should not appear in its place.
Sources
- Meta for Developers, General Data Protection Regulation (consent API
fbq('consent', 'revoke' | 'grant')): https://developers.facebook.com/docs/meta-pixel/implementation/gdpr - Meta for Developers, Meta Ads Data Advisor (formerly Meta Pixel Helper): https://developers.facebook.com/docs/meta-pixel/support/pixel-helper
- Meta Business Help Center, About Meta Ads Data Advisor: https://www.facebook.com/business/help/198406697184603
- Meta Business Help Center, Test events tool: verify app and web browser events for Meta: https://www.facebook.com/business/help/2040882565969969
- Google Tag Manager Help, Tag Manager consent mode support (Consent Settings, “Require additional consent for tag to fire”): https://support.google.com/tagmanager/answer/10718549