Use SignalPress.capture() or the alias sp_capture() in JavaScript when something happens in the browser and you want to send a signal through the same server-side routing as PHP sp_capture() — for example, send a signal to Slack or send a signal to PostHog from a button click.
PHP capture is covered in Capturing Events with sp_capture(). Compose sample calls in wp-admin with sp_capture Builder. For vendor browser SDKs and automatic page analytics, see Client-side analytics.
Client API
When SignalPress event delivery is enabled, the frontend loads a small client that POSTs to WordPress:
JavaScript
SignalPress.capture(
'checkout_started',
{
order_id: 123,
total: 49.95,
},
{
source: 'checkout-ui',
services: [ 'posthog', 'slack' ],
}
);
sp_capture() is an alias for the same function.
The third argument accepts the same options as PHP, including services, source, identity fields, and environment overrides. See Event Context and Options and Service Targeting.
Behavior
JavaScript capture:
- POSTs to
/wp-json/signalpress/v1/capturewith a REST nonce from the page - Runs
sp_capture()on the server with your event name, data, and options - Returns a Promise that resolves to
{ event, results, notices } - Creates normal delivery-ledger rows and respects routing, targeting, and hub operation mode
- Can trigger Capture toasts through the REST response and
X-SignalPress-Capture-Noticesheader
Validation mirrors PHP: normalized event names, JSON-serializable payloads, and a 1 MB encoded limit.
Requirements
- SignalPress → Settings — event delivery enabled
- The page must load
signalpress-client.js(automatic on public pages when delivery is enabled) - The browser must send the
X-WP-Nonceheader (handled automatically by the client) - Capture requests are rate limited per IP
Use PHP or authenticated theme AJAX when you need to capture from contexts that cannot load the SignalPress client.
Example: button click to Slack
JavaScript
document.querySelector('#notify-team').addEventListener('click', function () {
SignalPress.capture(
'hero_cta_clicked',
{ button: 'notify-team' },
{ source: 'marketing-theme', services: [ 'slack' ] }
);
});
What to read next
- sp_capture Builder — compose PHP or JavaScript calls in wp-admin
- Capturing Events with sp_capture() — PHP API
- Client-side analytics —
SignalPress.analytics()and vendor browser SDKs - Capture toasts — frontend confirmation notices
- Service Targeting — limit destinations
- Loading SignalPress Safely — when PHP capture is preferable