• Hi Meta Pixel for WordPress team,

    We use the Meta Pixel for WordPress plugin (currently v5.1.0) on client sites that are required to run a consent management platform (Usercentrics / IAB TCF / GDPR). To be compliant, the pixel <script> tags must not execute until the visitor grants consent — typically by rendering them as type="text/plain" with a data-usercentrics="..." (or equivalent) attribute, which the consent tool then activates after opt-in.

    The problem is that the plugin currently prints the pixel script tags directly. In core/class-facebookwordpresspixelinjection.php, inject_pixel_code() echoes hardcoded markup defined in core/class-facebookpixel.php (the $pixel_base_code property and get_pixel_init_code() / get_pixel_track_code()), all as <script type='text/javascript'>…</script>. Because these are echoed inline rather than registered through WordPress’s script API, there is no script_loader_tag filter and no markup filter we can hook into. Our only option today is full-page output buffering with a regex rewrite, which is fragile and has caused “headers already sent” conflicts with page builders.

    Could you please consider one of the following:

    1. Preferred: register the pixel scripts via wp_enqueue_script() / wp_register_script() and attach the inline pixel code with wp_add_inline_script(). This would let consent platforms and site owners modify the tag through the standard script_loader_tag filter (and properly handle the external fbevents.js load).
    2. Minimum: add a filter on the generated script markup (e.g. apply_filters( 'facebook_pixel_script_tag', $html, $context )) before it’s echoed, so the tag attributes can be modified without output buffering.

    Either change would make the plugin compatible with consent management out of the box and remove the need for fragile workarounds. Happy to provide more detail or test a build.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Marija

    (@marijastuntcoders)

    Hi @keyinora – thank you for reaching out!

    These updates are in the works, and we will update this thread with more information shortly.

    Kind regards,
    Marija

    Thread Starter keyinora

    (@keyinora)

    Hello Support!

    I just wanted to check in to see if you have an update for me?

    Plugin Support iodic

    (@iodic)

    Hello @keyinora, we will have an announcement soon for this feature. Sorry about the delay, we will get back to you asap.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.