• 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 ) { ... }
    

    or

    
    if ( ! fbq ) return;
    
    ...
    

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

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

    (@facebook)

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

    How are you blocking the script?

    Thread Starter Nicola Modugno

    (@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">
    !function(f,b,e,v,n,t,s)
    {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
    n.callMethod.apply(n,arguments):n.queue.push(arguments)};
    if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
    n.queue=[];t=b.createElement(e);t.async=!0;
    t.src=v;s=b.getElementsByTagName(e)[0];
    s.parentNode.insertBefore(t,s)}(window,document,'script',
    'https://connect.facebook.net/en_US/fbevents.js');
    fbq('init', '________'); 
    fbq('track', 'PageView');
    </script>
    

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

    Thread Starter Nicola Modugno

    (@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.