Consent Filters for Developers
This section is for developers who want to override consent behavior, disable specific pixels, or disable specific PixelYourSite cookies using WordPress filters.
In general:
- the filters return TRUE to disable something (pixel/cookie), or to enable a specific consent mode behavior.
- there’s one “master” filter to disable everything, plus filters for each platform/cookie.
Enable AJAX filter values update
When enabled, PixelYourSite updates consent-related filter values via AJAX, so changes can apply without a full page reload in some setups.
If you need to bypass this option from code, use:
pys_gdpr_ajax_enabled
Disable pixels via GDPR filters
Use these filters to disable tracking at runtime.
Disable all pixels
pys_disable_by_gdpr
ReturnTRUEto disable all pixels/tags.
Disable individual pixels
Return TRUE to disable only that platform:
pys_disable_facebook_by_gdprpys_disable_analytics_by_gdprpys_disable_tiktok_by_gdprpys_disable_google_ads_by_gdprpys_disable_pinterest_by_gdprpys_disable_bing_by_gdprpys_disable_reddit_by_gdpr
Typical use cases
- Disable tracking for specific regions/users/roles
- Implement custom consent logic (beyond what your CMP provides)
- Temporarily turn off a platform for testing
Disable cookies (PixelYourSite cookies)
Use these filters to stop PixelYourSite from creating certain cookies. Return __return_true (or TRUE) to disable the cookie(s).
Disable all PYS cookies
pys_disable_all_cookie
Session / limits
pys_disabled_start_session_cookie
Disablesstart_sessionandsession_limitcookies.
First visit
pys_disable_first_visit_cookie
Disablespys_first_visit.
Landing page
pys_disable_landing_page_cookie
Disablespys_landing_pageandlast_pys_landing_page.
Traffic source
pys_disable_trafficsource_cookie
DisablespysTrafficSourceandlast_pysTrafficSource.
UTM cookies
pys_disable_utmTerms_cookie
Disables UTM cookies for:utm_source,utm_medium,utm_campaign,utm_content,utm_term(bothpys_andlast_pys_).
Click ID cookies
pys_disable_utmId_cookie
Disables click-id cookies likefbadid,gadid,padid,bingid(bothpys_andlast_pys_).
Advanced data
pys_disable_advance_data_cookie
Disablespys_advanced_datacookies.
External ID (pbid / external_id)
pys_disable_externalID_by_gdpr
Disables thepbid(external_id)cookie.
Google alternative click-id
pys_disable_google_alternative_id
Disables the “Google alternative GCLID” cookie creation.
Example
Use the filter like this (in a custom plugin or your theme functions file):
add_filter('pys_disable_advance_data_cookie', '__return_true', 10, 2);
Google Consent Mode v2 support (filters)
These filters tell PixelYourSite to fire tags with specific Google Consent Mode values.
Format:
pys_{mode_name}_mode
Supported mode names shown:
analytics_storagead_storagead_user_dataad_personalization
Example
add_filter('pys_analytics_storage_mode', '__return_true');
This fires the pixel with consent mode analytics_storage: "granted".
Limited Data Use toggles (Meta / Reddit)
These filters enable or disable Limited Data Use options.
Meta LDU
pys_meta_ldu_mode
Example:
add_filter('pys_meta_ldu_mode', '__return_true');
Reddit LDU
pys_reddit_ldu_mode
Example:
add_filter('pys_reddit_ldu_mode', '__return_true');