# Custom events

> Send your own events from PHP or JavaScript, rename platform events, and add a platform of your own.

## Send an event

From PHP, before `wp_footer` runs. The event goes from the visitor's browser; only purchase, lead and sign_up also go from your server:

```php
do_action( 'ztta_track', 'newsletter_signup', [ 'value' => 1, 'currency' => 'USD' ] );
```

From JavaScript:

```js
window.ztta.track( 'newsletter_signup', { value: 1, currency: 'USD' } );
```

Meta, Google, TikTok, Pinterest, Microsoft Advertising and Reddit receive custom names as they are. Snapchat takes only `custom_event_1` to `custom_event_5`. X and LinkedIn skip custom events. An event with a value but no currency uses your shop's currency, or US dollars without WooCommerce.

Event parameters: `value`, `currency`, `items[]` (`id`, `name`, `quantity`, `price`), `transaction_id`, `search_term`, `content_name`, `form_id`.

## Rename or add platform event names

```php
add_filter( 'ztta_event_map', function ( $map, $provider, $channel ) {
    if ( 'meta' === $provider ) {
        $map['book_demo'] = 'Schedule';
    }
    return $map;
}, 10, 3 );
```

`$channel` is `browser` or `server`.

## Add a platform of your own

```php
add_action( 'ztta_register_providers', function ( $registry, $container ) {
    $registry->add( new MyProvider( /* … */ ) );
}, 10, 2 );
```

```js
window.ztta.adapter( 'myplatform', function ( ev, cfg, h ) {
    window.myPixel( 'track', ev.name, { value: h.val( ev.params ), currency: h.cur( ev.params ), dedup: ev.id } );
} );
```

## Filters

| Filter | Use |
|---|---|
| `ztta_event` | Change or drop any event before it's sent. |
| `ztta_consent_granted` | Override the consent decision. |
| `ztta_default_currency` | The currency for a value given without one. |
| `ztta_google_mp_host` | Send Measurement Protocol events to Google's EU host. |
| `ztta_order_is_renewal` | Mark a payment plugin's own renewal orders, so they follow **Send subscription renewals as purchases**. |
| `ztta_has_subscriptions` | Show the renewals switch without WooCommerce Subscriptions. |

Checked against Track Them All 1.0.5 on main, 19 October 2026.
