Actions & Filters

Log Test Activity

Fires on the visitors initial visit of a test and on conversion.

add_action('log_experiment_activity', 'custom_experiment_activity_handler', 10, 4); // $eid, $variation, $type ('visit' or 'conversion'), $location (page id)

Here’s example code where we take this data and log it

function custom_experiment_activity_handler($eid, $variation, $type, $location) {
// Custom code to handle the experiment activity data
// You can perform any necessary actions based on the data, like send events to GA, FB etc.

// Example: Logging the activity to a file
// $log = "Experiment Activity: Test ID=$eid, Variation=$variation, Type=$type, Location=$location, Visitor IP" . $_SERVER['REMOTE_ADDR'];
// my_log_function( $log );
}
add_action('log_experiment_activity', 'custom_experiment_activity_handler', 10, 4);

Disable Reporting Shortcode

add_filter( 'bt_ab_shortcode', '__return_false');

 

Hardcode License Key

add_filter('bb_bt_ab_licence_key',function(){
return 'yourlicencekey';
});

Is user tracking allowed

This filter defines if the current user can be tested on.

NOTE: this filter will run on every page load if you do not have website caching on. This can cause significant server load if incorrectly managed.

function my_custom_split_test_logic($is_allowed, $eid) {
  $user_is_eu = false; // you would have logic here
  if ($eid == '1234' && $user_is_eu) {
    return false; // don't allow testing on people from the EU
  }
  return $is_allowed; // In all other cases, defer to the default behavior
}
add_filter('abst_is_tracking_allowed', 'my_custom_split_test_logic', 10, 2);

Allow cross domain ajax requests

Useful for if you have multisite domain mapping and are getting ajax errors with visits and conversions.

add_filter( 'abst_allow_cors', '__return_true' );

Change required confidence for test winner calculation

By default, we wait for a 95% confidence interval before calling a test winner. Change it with this filter.

add_filter('ab_complete_confidence',function(){ return 98; }); // change to 98% confidence

JavaScript Events

See our article on JavaScript events

Leave a Comment

You must be logged in to post a comment.