Hooks
modal_kit_pro_results_goal
filter
Pro
PHP
Choose what counts as a conversion for a modal on Results: played, signed up, coupon used, watched, clicked or added to cart.
Each modal has one main goal, worked out from its content: a game is played, a Pro form is signed up to, a woo-apply-coupon button is used, a video or embed is watched, and otherwise any link or button is clicked (except closing, copying and moving between steps). One conversion counts per showing.
Runs when a modal is printed (the goal goes in the page, and the browser only reports that kind of conversion), and when Results and the modal list work out conversion rates.
Parameters
Parameter
Description
$goal
string
played, signed_up, coupon, watched or clicked.
$post
WP_Post
The modal.
Returns
string One of played, signed_up, coupon, watched, clicked or added_to_cart. Anything else becomes clicked.
Examples
Count clicks on a modal with a form
A sale modal has a newsletter form, but the button to the sale matters more.
add_filter( 'modal_kit_pro_results_goal', function ( $goal, $post ) {
if ( 'summer-sale' === $post->post_name ) {
return 'clicked';
}
return $goal;
}, 5, 2 );
Count adding to the cart
Modals with an add-to-cart button count a product added from the modal.
add_filter( 'modal_kit_pro_results_goal', function ( $goal, $post ) {
if ( false !== strpos( $post->post_content, 'woo-add-to-cart' ) ) {
return 'added_to_cart';
}
return $goal;
}, 5, 2 );
Good to know
While an A/B test is running, paused or ended, Pro sets the test’s own goal through this filter at priority 10. The examples use priority 5 so tests keep their goal.
Results reads conversions for the current goal only, so after a change the rate counts only conversions recorded since.
Pages already in a page cache keep the old goal until they’re refreshed.
Applied in modal-kit-pro/includes/Results.php.