Support » Plugin: Facebook for WordPress » Blocked script and “Uncaught ReferenceError: fbq is not defined”

  • Hello,
    I developed Smart Cookie Kit, a plugin that helps sites admins to block cookies (for the GDPR) and to unlock them if the visitor accept the policies.

    When Smart Cookie Kit (but also other plugins that really make a server-side block) blocks the FB external script, the error “fbq is not defined” is raised up by the following JavaScript.

    As the base code of the pixel is splitted in separated script tags (script load, pixel init, pageview track), could you modify the code for the “fbq” tasks testing if the object is defined?

    I think that something similar could be sufficient

    if ( fbq ) { ... }


    if ( ! fbq ) return;

    Hope to get a feedback from you.
    Regards, Nicola.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Facebook


    Thanks for your feedback. We are looking into cookie consent management.

    How are you blocking the script?

    Thread Starter shark986


    SCK modifyes scripts server side in different ways. The script tag like the FB Pixel is blocked changing the “type” property:

    <script type="text/blocked" data-sck_type="1" data-sck_unlock="profiling" data-sck_ref="Facebook Pixel" data-sck_index="1" class="BlockedBySmartCookieKit">
    fbq('init', '________'); 
    fbq('track', 'PageView');

    When a user accept cookies, SCK executes the script appending (and unlocking) its tag to the body of the page.

    Thread Starter shark986


    Hello… Any update/decision on this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Blocked script and “Uncaught ReferenceError: fbq is not defined”’ is closed to new replies.