When true, the event tracking REST endpoint returns 403 Forbidden for requests whose referer is from a different domain.
Alpha Insights validates that the request referer matches the site in some cases. If you want to block all events that come from a different host (e.g. to prevent cross-site event injection), return true from this filter. When the referer is considered "foreign," the API responds with a 403 and message "Forbidden request." (code invalid_referer). Default is false.
File: includes/classes/WPDAI_Woocommerce_Event_Tracking.php
Context: REST request validation when the referer host does not match the site host.
| Parameter | Type | Description |
|---|---|---|
| (none) | — | No parameters passed. Return true to block foreign referers; false to allow. |
Type: bool
True to block the request (403); false to allow it (default).
add_filter( 'wpd_ai_event_tracking_prevent_foreign_referrals', '__return_true' );
add_filter( 'wpd_ai_event_tracking_prevent_foreign_referrals', 'block_foreign_referers_in_production' );
function block_foreign_referers_in_production() {
return wp_get_environment_type() === 'production';
}