Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created December 10, 2025 13:28
Show Gist options
  • Select an option

  • Save xlplugins/b12507742af229a22f32ebb142b223e4 to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/b12507742af229a22f32ebb142b223e4 to your computer and use it in GitHub Desktop.
Add Plausible analytics tracking class to FunnelKit Checkout place order button
add_filter( 'woocommerce_order_button_html', function( $button_html ) {
// Check if we're on a FunnelKit checkout page
if ( ! function_exists( 'wfacp_template' ) ) {
return $button_html;
}
$instance = wfacp_template();
if ( ! $instance ) {
return $button_html;
}
// Add Plausible event class to the button
// Handle both <button> and <input> element types
if ( strpos( $button_html, '<button' ) !== false ) {
// For <button> elements, add class to existing class attribute
$button_html = preg_replace(
'/(<button[^>]*class=["\'])([^"\']*)(["\'])/i',
'$1$2 plausible-event-name=Complete+purchase$3',
$button_html
);
} elseif ( strpos( $button_html, '<input' ) !== false ) {
// For <input> elements, add class to existing class attribute
$button_html = preg_replace(
'/(<input[^>]*class=["\'])([^"\']*)(["\'])/i',
'$1$2 plausible-event-name=Complete+purchase$3',
$button_html
);
}
return $button_html;
}, 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment