Some Klaviyo scripts do not have a script handle in the frontend HTML
-
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.
- You must be logged in to reply to this topic.