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:

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.

  1. Open a private (incognito) window, so no earlier consent choice is remembered.
  2. Open the browser’s developer tools (F12, or right-click and choose Inspect) and go to the Network tab.
  3. Type facebook.com/tr into the Network filter box.
  4. Load your page. Do not click anything on the cookie banner.
  5. If requests to facebook.com/tr appear while the banner is still on screen, the pixel is firing before consent. The pixel usually sends events with sendBeacon, so in Chrome they may be listed with the type ping rather than fetch or img. Click a request and look at its payload: id is your pixel ID and ev is the event name (for example PageView).

You can also check with:

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.

  1. 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.js and fbq(. The fix only works if every copy goes through your consent setup.
  2. 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_data and ad_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') before fbq('init', ...) on every page load, and call fbq('consent', 'grant') when the visitor accepts marketing cookies. Meta documents this as pausing pixel sends until consent is granted.
  3. 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.
  4. Publish your changes and clear any site or CDN cache.

Common causes

How to verify the fix

  1. Repeat the private-window test above: no facebook.com/tr requests before you answer the banner, and requests appear right after you click “Accept”.
  2. Click “Reject” in a fresh private window: no facebook.com/tr requests at all.
  3. 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