Facebook / Meta GDPR consent

Have more questions? Submit a request

Facebook has enabled support for managing cookies that are set by their advertising pixels. For this you need to make a few adjustments. More information can be found here.


Changing your Facebook Pixel code

Copy the code below and add the pixel ID in the Init. The difference with your default pixel code is that by default consent is set to revoke, this means no cookies are set before consent has been given.

s.parentNode.insertBefore(t,s)}(window, document,'script',
fbq('consent', 'revoke'); //add this line above init
fbq('init', 'YOUR FB PIXEL ID');
fbq('track', 'PageView');

Add helper script 

Add the following script under the FB pixel code to make the banner fire an event to update consent when in this case the advertising category is accepted by the user. This will set the cookies from Facebook.

function callbackFnc(e) {
var consent = e.detail || CookieFirst.consent;
// no consent yet or advertising not accepted, return
if (!consent || !consent.advertising) {
} else {
fbq('consent', 'grant');
window.addEventListener("cf_consent", callbackFnc);
window.addEventListener("cf_init", callbackFnc);

Articles in this section

Was this article helpful?
2 out of 3 found this helpful