Event Filters
Version 1.51.0 of the Pixel Manager
Customize event tracking data for all pixels using JavaScript (front-end) and PHP (server-side) filters.
Why Use the Command Queue?
Always wrap your filters in the Pixel Manager command queue:
window._pmwq = window._pmwq || [];
window._pmwq.push(function() {
pmw.hooks.addFilter('pmw_pixel_data_facebook', 'my-plugin', function(pixelData) {
pixelData.custom_data.custom_field = 'my_value';
return pixelData;
});
});
Why? Caching systems and JavaScript optimizers may shuffle, combine, or delay script loading. The command queue provides a 100% reliable way to ensure your filters register after Pixel Manager loads, preventing race conditions and initialization errors. Without it, pmw.hooks may not exist yet, causing your code to fail silently.
Adding to WordPress:
add_action('wp_head', function() {
?>
<script>
window._pmwq = window._pmwq || [];
window._pmwq.push(function() {
pmw.hooks.addFilter('pmw_pixel_data_facebook', 'my-plugin', function(pixelData) {
pixelData.custom_data.custom_field = 'my_value';
return pixelData;
});
});
</script>
<?php
}, 1); // Priority 1 to load early in <head>
Planning Your Filters
Before implementing filters, consider where your events are processed:
Front-End vs. Server-Side Events
Front-end events (processed in the browser):
- All events when server-to-server tracking is disabled
- Events like
add_to_cart,view_item,begin_checkout, etc. - Purchase events only if processed through the browser
Server-side events (processed on the server):
- Purchase events when server-to-server tracking is enabled (Facebook CAPI, TikTok EAPI, Pinterest APIC, Snapchat CAPI)
- Google Analytics purchase events when Measurement Protocol is enabled
- These are always sent from the server, never through the browser
Why server-side purchase events? Browser-based tracking can be blocked by ad blockers, browser extensions, privacy settings, or network-level filters. When server-to-server tracking is enabled, purchase events are compiled and sent directly from your server to the advertising platforms, completely bypassing the browser. This makes them immune to client-side blocking, ensuring 100% reliable conversion tracking. The tradeoff is that these events are processed in a completely independent pipeline, which means they require separate filters.
When server-to-server tracking is active, purchase events are compiled and sent exclusively from the server. This means:
- Front-end filters will NOT affect these purchase events
- You must implement PHP server-side filters to modify purchase event data
Example: To filter purchase events with server-to-server tracking enabled, you need both:
// Front-end (for any browser-based purchase events)
window._pmwq.push(function() {
pmw.hooks.addFilter('pmw_event_payload_purchase', 'my-filter', function(payload) {
payload.event_data.custom_field = 'value';
return payload;
});
});
// Server-side (REQUIRED for server-to-server purchase events)
add_filter('pmw_server_event_payload_event_purchase', function($pixel_data, $pixel_name, $event_name) {
$pixel_data['custom_data']['custom_field'] = 'value';
return $pixel_data;
}, 10, 3);
Always implement server-side filters when working with purchase events if you have server-to-server tracking enabled.