Filters

Visitor tracking

shrimptest_blocked_visit

Control whether a request is “blocked”, so ShrimpTest will not be active for this visit, even for the variant preview functionality. All experiments will return with the control variant.

Parameters:

  1. boolean – if returned true, the visit will be “blocked”
  2. string – the user agent string of the visitor

Example: used by plugins/plugin-blocklist.php to block bots

shrimptest_exempt_visitor

Control whether a visit is “exempt” and not counted. When a visit is “exempt,” ShrimpTest will still operate, for example, to support the variant preview feature.

Parameters:

  1. boolean – if returned true, the visit will be “exempt”

Example: used by plugins/plugin-prefetch-block.php to not count prefetch requests

shrimptest_blockterms

A filter for the blacklist of terms which, if one shows up in the user-agent, we block the visitor from ShrimpTest behavior. The visitor is not blocked from the site. See the filter shrimptest_blocked_visit.

Parameters:

  1. array – array of strings which may show up in user-agent strings

Used in plugins/plugin-blocklist.php

shrimptest_blocklist

A filter for the list of complete user-agents which are blocked from ShrimpTest behavior. See the filter shrimptest_blocked_visit.

Parameters:

  1. array – array of user-agent strings

Used in plugins/plugin-blocklist.php

shrimptest_cookie_domain

Used to modify the domain used for the ShrimpTest cookie.

Parameters:

  1. string – cookie domain

shrimptest_cookie_path

Used to modify the root path used for the ShrimpTest cookie.

Parameters:

  1. string – cookie path

shrimptest_cookie_name

The cookie name used for the ShrimpTest cookie.

Parameters:

  1. string – cookie name, default: “ebisen”

shrimptest_cookie_days

The Shrimptest cookie timeout, in days.

Parameters:

  1. int – cookie timeout in days

“Touches”

The “touches” system keeps track of what experiments are “touched” throughout the course of the execution. Various subsystems, like the caching support plugin and variant preview feature, use its results.

shrimptest_record_touched_is_404

Returns true when the page is a 404, and shouldn’t be a target of caching in the cache-support plugin.

Parameters:

  1. boolean – true if it’s a 404 page

shrimptest_touched_experiments

Called in the $shrimp global ShrimpTest instance’s get_touched_experiments() method. “Touched” experiments are those experiments and variants who have been consulted throughout execution.

Parameters:

  1. array – keys are experiment ids, values are arrays with information on each experiment in this execution

shrimptest_touched_metrics

Called in the $shrimp global ShrimpTest instance’s get_touched_metrics() method. “Touched” metrics are those which have recorded a visitor’s metric value during execution.

Parameters:

  1. array – keys are experiment ids, values are arrays with information on the metric recording which happened

shrimptest_cache_support_request_uri

Modify the request URI used as the unique key for caching by the cache-support plugin.

Parameters:

  1. string – URI

Database

shrimptest_db_prefix

The namespacing prefix string used in naming database tables used by ShrimpTest. By default is the wpdb prefix (normally ‘wp_’) followed by ‘shrimptest_’.

Parameters:

  1. string – the prefix string

shrimptest_dbdelta_sql

Modifies the list of SQL queries passed to the dbDelta function to set up ShrimpTest tables. Please see the documentation for dbDelta.

Parameters:

  1. array – values are strings with SQL CREATE TABLE statements

Example: used by plugins/plugin-cache-support.php to add additional tables for cache support.

Admin interface

shrimptest_interface_slug

The ShrimpTest interface slug is the string used in wp-admin URL’s for the ShrimpTest admin pages. By default it is ‘shrimptest’.

Parameters:

  1. string – the slug string

shrimptest_get_variant_types_to_edit

A structured array of variant types to show up in the ‘Add new experiment’ screen’s variant type dropdown.

Parameters:

  1. array – keys are internal variant names, values are stdObjects with the properties below.
  2. string – the current variant type of the experiment

Properties which the array values can have:

  • ‘label’: the display string for the variant type
  • ‘disabled’: boolean for whether the user can select this type or not

shrimptest_get_metric_types_to_edit

A structured array of metric types to show up in the ‘Add new experiment’ screen’s metric type dropdown.

Parameters:

  1. array – keys are internal metric names, values are stdObjects with the properties below.
  2. string – the current metric type of the experiment

Properties which the array values can have:

  • ‘label’: the display string for the metric type
  • ‘disabled’: boolean for whether the user can select this type or not

shrimptest_admin_experiment_row_actions

Applied to the array of “actions” that are printed under a particular experiment.

Parameters:

  1. array – actions array, with “action type” keys (which are translated into <span> class’s, and link html as values
  2. int – experiment id

Experiment stats

shrimptest_stats_timeout

Controls the interval of time after which experiment statistics must be recalculated.

Parameters:

  1. int – the timeout, in seconds. Default: 3600 (1 hour)

shrimptest_stats_transient

The prefix used to name experiment stats when caching them in the Transients API.

Parameters:

  1. string – the prefix. Default: ‘shrimptest_stats_’. The experiment id will be suffixed.

shrimptest_get_stats_value_*

For every metric type with internal name <metric>, the shrimptest_get_stats_value_<metric> filter can be used to change the SQL expression used to compute the aggregate “value” of the metric. This matters in cases where a single visitor has ended up recording multiple metric values for a particular metric.

Parameters:

  1. string – SQL expression involving the column ‘value’. Defaults are ‘max(ifnull(value,0))’ or ‘max(value)’ depending on the metric’s ifnull and direction parameters.

shrimptest_experiment_stats

A filter for the experiment stats array. See the description of the get_shrimptest_stats() method in the classes/model.php file for a detailed description of the format.

Parameters:

  1. array – the stats array

Custom metric

shrimptest_save_metric_*

For a given metric called <metric>, the shrimptest_save_metric_<metric> filter is applied right before saving the metric specification in experiment-save.php.

Parameters:

  1. array – the metric data

shrimptest_display_metric_*_value

For a given metric called <metric>, the shrimptest_display_metric_<metric>_value filter is used to get a display string for a particular metric’s value.

Parameters:

  1. string – the metric value string
  2. float – the numeric value, rounded to four digits. Used as the default display string.
  3. float – the raw value

Example: used in plugins/metric-conversion.php to format conversion metrics as percentages.

Actions

shrimptest_init

Called right after ShrimpTest has been loaded.

Parameters:

  1. ShrimpTest – a reference to the global ShrimpTest object

Admin interface

shrimptest_admin_header

Called when printing scripts and styling at the top of ShrimpTest admin pages.

Examples: used in the plugins/variant-shortcode.php and plugins/metric-conversion.php to add styling and JavaScript for the additional interface elements for that variant and metric.

shrimptest_add_variant_extra

Called during generation of the #shrimptest_variants table in the ‘Add New Experiment’ screen, where custom variant types can add special form elements.

Examples: plugins/variant-shortcode.php and plugins/variant-title.php

shrimptest_add_metric_extra

Called during generation of the #shrimptest_metrics table in the ‘Add New Experiment’ screen, where custom metric types can add special form elements.

Example: plugins/metric-conversion.php

shrimptest_add_duration_extra

Called during generation of the #shrimptest_duration table in the ‘Add New Experiment’ screen, where custom form elements can be added .

Example: plugins/plugin-notification.php

Experiment life cycle

shrimptest_update_experiment_status

Called when an experiment’s status is updated.

Parameters:

  1. int – experiment id
  2. string – new experiment status: “reserved”, “inactive”, “active”, or “finished”

Example: used in plugins/plugin-cron-stats.php to set up a Cron schedule for an experiment when it’s activated, and takes it down when the experiment finishes.

shrimptest_update_variants_type

Called when an experiment’s variant type is changed.

Parameters:

  1. int – experiment id
  2. string – the new variant type string

shrimptest_experiment_duration_reached

Called when an experiment’s planned duration is reached.

Parameters:

  1. array – the stats array for the experiment, formatted as described in the comment on the get_shrimptest_stats() method in classes/model.php
  2. array – experiment specification array

Used by plugins/plugin-notification.php to send out a notification email when the experiment duration is reached.

shrimptest_calculate_stats

Called by the WP Cron when the scheduled stat computation time is reached. Used internally in plugins/plugin-cron-stats.php