PixelYourSite Filters and Hooks
Use these WordPress filters to customize PixelYourSite tracking without editing plugin files. Add snippets in a small custom plugin or your theme’s functions.php.
General rule: most “disable” filters work by returning true.
GDPR / Consent Controls
pys_disable_by_gdpr — Disable all pixels
Disables sending events for all pixels. Useful for custom GDPR logic.
Param: bool $status
add_filter('pys_disable_by_gdpr', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_disable_{pixel}_by_gdpr — Disable a specific pixel
Disable events for a single platform.
Pixel slugs: facebook, google_ads, ga, tiktok, pinterest, bing
Param: bool $status
add_filter('pys_disable_facebook_by_gdpr', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_gdpr_ajax_enabled — Refresh consent status via AJAX
Loads the latest GDPR pixel status before loading web pixels. Helpful on cached sites.
Param: bool $status
add_filter('pys_gdpr_ajax_enabled', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_check_consent_by_gdpr — Override consent status
Programmatically override consent status (for custom CMPs / privacy workflows).
Param: bool $status
add_filter('pys_check_consent_by_gdpr', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
Event Data / Events Control
pys_event_data — Edit event payload
Edit/add custom data before an event is sent.
Params: array $data, string $slug, any $context
add_filter('pys_event_data', function ($data, $slug, $context) {
if (get_current_user_id() == 0) {
$data['params']['total'] = 0;
}
return $data;
}, 10, 3);
pys_validate_pixel_event — Disable specific events (per pixel + event)
Use custom logic to disable an event for a specific pixel.
Params: bool $isActive, PixelYourSitePYSEvent $event, PixelYourSiteSettings $pixel
add_filter('pys_validate_pixel_event', function ($isActive, $event, $pixel) {
if (
$pixel->getSlug() == "facebook" &&
$event->getId() == "woo_purchase" &&
get_current_user_id() == 0
) {
return false;
}
return $isActive;
}, 10, 3);
pys_disable_server_event_filter — Disable server-side events (CAPI / API)
Blocks server-side events for Facebook CAPI, TikTok Events API, Pinterest Conversions API, and GA4 Measurement Protocol.
Params:
bool $disable(returntrueto block)string $event_name(event slug)string $tag_slug(facebook,tiktok,pinterest,ga4)int|null $order_id
Example: block REST API orders (Woo)
add_filter('pys_disable_server_event_filter', function($disable, $event_name, $tag_slug, $order_id) {
if ($event_name === 'woo_purchase' && $order_id) {
$order = wc_get_order($order_id);
if ($order && $order->get_created_via() === 'rest-api') return true;
}
return $disable;
}, 10, 4);
Example: block all events for pending orders
add_filter('pys_disable_server_event_filter', function($disable, $event_name, $tag_slug, $order_id) {
if ($order_id) {
$order = wc_get_order($order_id);
if ($order && $order->get_status() === 'pending') return true;
}
return $disable;
}, 10, 4);
Example: block only Facebook purchase server event
add_filter('pys_disable_server_event_filter', function($disable, $event_name, $tag_slug, $order_id) {
if ($event_name === 'woo_purchase' && $tag_slug === 'facebook') return true;
return $disable;
}, 10, 4);
Event slugs (quick reference)
- Other:
init_event,custom - Woo:
woo_purchase,woo_view_content,woo_view_category,woo_view_cart,woo_initiate_checkout,woo_add_to_cart_on_button_click, etc. - EDD:
edd_purchase,edd_view_content,edd_view_category,edd_initiate_checkout,edd_add_to_cart_on_button_click, etc. - Automatic:
automatic_event_scroll,automatic_event_video,automatic_event_form,automatic_event_download, etc. - CartFlows:
wcf_view_content,wcf_add_to_cart_on_next_step_click,wcf_bump, etc.
Currency / Order ID Helpers
pys_currencies_list — Add custom currency
Adds a new currency option (used in custom events).
Param: array $currencies
add_filter('pys_currencies_list', function ($currencies) {
$currencies['PTH'] = 'Test';
return $currencies;
});
pys_{edd|woo}_checkout_order_id — Override order id on checkout
Use a custom order ID source (for custom checkout flows).
pys_edd_checkout_order_idpys_woo_checkout_order_id
Param: int $order_id
add_filter('pys_woo_checkout_order_id', function ($order_id) {
if (isset($_GET['custom_order_param_with_id'])) {
return $_GET['custom_order_param_with_id'];
}
return $order_id;
});
Pixel IDs / Advanced Matching (Meta)
pys_pixel_disabled — Disable all pixels or specific pixel IDs
Return ['all'] to disable all pixels, or return an array of IDs to disable only those.
Params: bool $isActive, string $pixelSlug
Return: array|bool
Disable all:
add_filter('pys_pixel_disabled', function ($isActive, $pixelSlug) {
if (get_current_user_id() == 0 && $pixelSlug == 'facebook') {
return ['all'];
}
return $isActive;
}, 11, 2);
Disable specific IDs:
add_filter('pys_pixel_disabled', function ($isActive, $pixelSlug) {
if (get_current_user_id() == 0 && $pixelSlug == 'facebook') {
return ['1123450378576095', '1300447800692613'];
}
return $isActive;
}, 11, 2);
pys_{pixel}_ids — Add pixel IDs dynamically
Add IDs based on your logic.
Pixel slugs: facebook, google_ads, ga, tiktok, pinterest, bing
Param: array $ids
add_filter('pys_facebook_ids', function ($ids) {
if (get_current_user_id() == 0) $ids[] = 'CUSTOM_PIXEL_ID';
return $ids;
});
pys_fb_advanced_matching — Edit Meta browser advanced matching
Param: array $params
add_filter('pys_fb_advanced_matching', function ($params) {
if (get_current_user_id() == 0) {
$params['fn'] = "not_registered";
$params['ln'] = "not_registered";
}
return $params;
});
pys_fb_server_user_data — Edit Meta server-side user data
Param: PYS_PRO_GLOBALFacebookAdsObjectServerSideUserData $userData
add_filter('pys_fb_server_user_data', function ($userData) {
if (get_current_user_id() == 0) {
$userData->setFirstName("undefined");
$userData->setLastName("undefined");
$userData->setEmail("undefined");
}
return $userData;
});
pys_before_send_fb_server_event — Edit the Meta server event object
Params: FacebookAdsObjectServerSideEvent $event, string $pixel_Id, string $eventId
add_filter('pys_before_send_fb_server_event', function ($event, $pixel_Id, $eventId) {
if (get_current_user_id() == 0) {
$event->setActionSource("not_registered");
}
return $event;
}, 10, 3);
Cookie Controls
pys_disable_all_cookie — Disable all PYS cookies
Param: bool $status
add_filter('pys_disable_all_cookie', function ($status) {
$user = wp_get_current_user();
$roles = (array) $user->roles;
if (in_array('administrator', $roles)) return true;
return $status;
});
Disable cookie groups (same principle)
pys_disabled_start_session_cookiepys_disable_first_visit_cookiepys_disable_landing_page_cookiepys_disable_trafficsource_cookiepys_disable_utmTerms_cookiepys_disable_utmId_cookiepys_disable_advance_data_cookiepys_disable_externalID_by_gdpr
pys_disable_google_alternative_id — Disable alternative GCLID cookie
Disables Google alternative GCLID cookie creation (Safari compatibility feature).
Param: bool $status
add_filter('pys_disable_google_alternative_id', function ($status) {
$user = wp_get_current_user();
$roles = (array) $user->roles;
if (in_array('administrator', $roles)) return true;
return $status;
});
Consent Mode / LDU / URL passthrough
pys_{mode}_mode — Google Consent Mode
Mode names:
analytics_storagead_storagead_user_dataad_personalization
Param: bool $mode
add_filter('pys_analytics_storage_mode', function ($mode) {
if (get_current_user_id() == 0) return true;
return $mode;
});
When enabled, consent mode will be sent as "granted" for that mode.
pys_bing_ad_storage_mode — Bing consent mode
Param: bool $mode
add_filter('pys_bing_ad_storage_mode', function ($mode) {
if (get_current_user_id() == 0) return true;
return $mode;
});
pys_url_passthrough_mode — Toggle URL passthrough option
Param: bool $status
add_filter('pys_url_passthrough_mode', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_meta_ldu_mode — Toggle Meta Limited Data Use
Param: bool $status
add_filter('pys_meta_ldu_mode', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_reddit_ldu_mode — Toggle Reddit Limited Data Use
Param: bool $status
add_filter('pys_reddit_ldu_mode', function ($status) {
if (get_current_user_id() == 0) return true;
return $status;
});
pys_send_meta_id — Allow/disallow fb_login_id from Social Connect
Controls sending the fb_login_id parameter (from the Social Connect plugin).
Param: bool $status
add_filter('pys_send_meta_id', function ($status) {
if (get_current_user_id() == 1) return false;
return $status;
});