Streaming live at 10am (PST)

Webflow Guide for Facebook Pixel consent working only 90%


I’m currently setting up Facebook Pixel consent following The Webflow guide here:

I’ve designed the banner, added the animations and added the JS code to make the local storage.

And it does work 90%.

So when a user enters the site the first time he will get the banner, and when he clicks “Grant”, Facebook will fire the pixel.

But if the user refreshes the site, the banner will now be gone, but the Facebook pixel does not fire.

From my understanding, the script below should check if FB is granted, and if it is, it should be fired.

Here is link to the test site:
(I’ve also tried it on live site, but no luck)

So my guess is that there is something wrong with the JS provided by Webflow (?)

This is the JS:

 <script type='text/javascript'>
 var popup = document.getElementById('consentPopup');
 var alreadyLoaded = window.localStorage.getItem('fbGrantConsent') === 'true';

//Show the consent banner if consent is not granted, hide it if consent is already granted.
 if (alreadyLoaded) { = 'none';
   fbq('consent', 'grant');
 } else { = 'block';

//Grant consent and store it in localStorage of the browser
 var consentBtn = document.getElementById('consentBtn');
 consentBtn.addEventListener("click", function() {
 fbq('consent', 'grant');
   window.localStorage.setItem('fbGrantConsent', 'true');


Any suggestions? :slight_smile:

I’ve had the exact same problem. It’s strange as I’ve seen similar methods explained elsewhere, so is the problem with this code or the Facebook Pixel Helper not updating?

I managed to fix this by adding a delay of 300ms to the consent line.

 if (alreadyLoaded) { = 'none';
   setTimeout(function() { fbq('consent', 'grant') }, 300);
 } else { = 'block';
1 Like

Thanks for sharing, this fixed it for me as well!