• Resolved robertrosanke

    (@robertrosanke)


    Hello.

    We have adapted our cookie banner service (Borlabs Cookie WordPress Plugin) to make Klaviyo compatible with it.

    This was partly difficult because Klaviyo does not provide script handles everywhere.

    e.g. for widgets or the general klaviyo script.

    Please add the script handle to the function “kl_add_async” in wp-content/plugins/klaviyo/inc/kla-analytics.php.
    This makes it easier for Cookie-Tols to work with Klaviyo.

    Working code example:

    public function kl_add_async( $tag, $handle, $src ) {
    if ( self::KLAVIYO_JS_HANDLE !== $handle ) {
    return $tag;
    }

    return "<script id=\"".esc_attr($handle)."\" async src='" . esc_url($src) . "'></script>"; // phpcs:ignore
    }

    We do not currently use the widget forms.
    There, a unique ID can also be helpful to block the widget-HTML via Borlabs Cookie Content Blocker until the opt-in by the user.
    But the widget issue is of secondary importance to us for now.

    The klaviyo script is more important.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter robertrosanke

    (@robertrosanke)

    Quick question: Will the issue be resolved in the next plugin update?

    Note: wp_enqueue_script() now also natively supports async behavior via $args['startegy'=>'async']. It is no longer necessary to manipulate the tag before output.

    Plugin Author klaviyo

    (@klaviyo)

    Hello, thank you for sharing this use case and working code example. I have submitted a feature request on your behalf! That said, note that there is currently no estimated timeline associated with this feature request so you should continue to use your customization until this update has been implemented in a future version of the plugin.

    Thread Starter robertrosanke

    (@robertrosanke)

    Thanks for the info.
    We’ll stick with the manual solution for now and hope for a fix soon.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.