Actions #
| Hook | Fires when |
|---|---|
| opti_behavior_ab_variant_served | A variant is served |
| opti_behavior_ab_test_status_changed | A test changes status |
| opti_behavior_ab_winner_declared / _applied / _reverted | A winner is declared, applied or reverted |
| opti_behavior_smart_insights_register_signals | The signal registry is built – register custom signals |
| opti_behavior_smart_insights_rules_upgraded | Smart Insights rules changed version |
| opti_behavior_funnel_created | A funnel is created |
Filters #
| Filter | Lets you |
|---|---|
| opti_behavior_funnel_site_context / _funnel_recipes / _funnel_recipe_steps | Adjust site detection and suggested funnels |
| opti_behavior_smart_insights_category_labels | Rename Smart Insights categories |
| opti_behavior_smart_insights_critical_min_lost | Change the Critical floor |
| opti_behavior_smart_insights_purchase_funnel | Mark a funnel as a purchase funnel |
| opti_behavior_defer_tracker_scripts / opti_behavior_use_minified_js | Control defer and minified trackers |
| opti_behavior_consent_cookie_days | Change how long consent is remembered |
| opti_behavior_visitor_ip | Adjust the visitor IP detection |
| opti_behavior_funnel_entry_rate_limit / opti_behavior_geo_lookups_per_minute | Tune rate limits |
| opti_behavior_should_purge_cache | Decide whether a funnel change purges page caches |
| opti_behavior_ab_cookie_requires_consent | Opt out of the A/B consent gate (not recommended) |
Example #
add_filter( 'opti_behavior_consent_cookie_days', function () { return 365; } );
Hooks can change between major versions; check the changelog when you update.
Related articles #
- Data storage
- Cache plugin compatibility
- Tracking not working checklist
- Performance FAQ
- Contacting support
Best practices #
- Put your code in a small custom plugin or a child theme, never in Opti-Behavior files.
- Check
function_exists/class_existsbefore calling plugin classes. - Test on staging after each major update.
Example: exclude an internal tool from bot detection #
Add its user-agent fragment in Settings → Traffic & Behavior → Custom Bot Patterns – no code needed.
Example: trust your own proxy header #
add_filter( 'opti_behavior_visitor_ip', function ( $ip ) { return isset( $_SERVER['HTTP_X_CLIENT_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_CLIENT_IP'] ) ) : $ip; } );
Only do this when the header is set by your own infrastructure; otherwise visitors could fake their IP.