Integrates Umami Analytics with WooCommerce to automatically track key ecommerce events via Umami custom events.
- WordPress 5.8+
- WooCommerce 6.0+
- PHP 8.0+
- An Umami Analytics instance with a Website ID
- Upload the
umami-woocommerce-trackingfolder to/wp-content/plugins/. - Activate the plugin through Plugins → Installed Plugins.
- Go to WooCommerce → Settings → Integration → Umami Tracking.
- Enter your Umami Script URL and Website ID.
- Check Enable Tracking and save.
That's it — events will start flowing into your Umami dashboard.
| Event | Trigger | Payload Keys |
|---|---|---|
product_view |
Single product page loaded | product_id, product_name, price, currency, category |
add_to_cart |
Product added (single page, AJAX, or archive) | product_id, product_name, price, quantity, currency, category |
remove_from_cart |
Item removed from cart | product_id, product_name, quantity_removed |
view_cart |
Cart page loaded | cart_total, total_items, product_ids, currency |
begin_checkout |
Checkout page loaded | cart_total, total_items, currency |
purchase |
Thank-you / order-received page loaded | order_id, total_value, currency, products (JSON string) |
Each event can be individually toggled on/off from the settings page.
{
"product_id": 42,
"product_name": "Classic T-Shirt",
"price": 29.99,
"currency": "USD",
"category": "Clothing"
}{
"product_id": 42,
"product_name": "Classic T-Shirt",
"price": 29.99,
"quantity": 2,
"currency": "USD",
"category": "Clothing"
}{
"product_id": 42,
"product_name": "Classic T-Shirt",
"quantity_removed": 1
}{
"cart_total": 59.98,
"total_items": 2,
"product_ids": "42,55",
"currency": "USD"
}{
"cart_total": 59.98,
"total_items": 2,
"currency": "USD"
}{
"order_id": 1234,
"total_value": 64.97,
"currency": "USD",
"products": "[{\"id\":42,\"name\":\"Classic T-Shirt\",\"quantity\":2,\"price\":29.99},{\"id\":55,\"name\":\"Cap\",\"quantity\":1,\"price\":4.99}]"
}Found at WooCommerce → Settings → Integration → Umami Tracking:
| Field | Description |
|---|---|
| Enable Tracking | Master on/off switch. |
| Umami Script URL | Full URL to your Umami JS file (e.g. https://analytics.example.com/script.js). |
| Website ID | The UUID from your Umami dashboard. |
| Debug Mode | Logs every umami.track() call to the browser console. |
| Event Toggles | Enable/disable each event type individually. |
umami_wc_event_enabled( bool $enabled, string $event )— Dynamically enable/disable a specific event.umami_wc_event_data( array $data, string $event_name )— Modify any event payload before it reaches the frontend.umami_wc_event_data_{event_name}( array $data )— Modify a specific event's payload (e.g.umami_wc_event_data_purchase).
umami_wc_before_product_view( array $data, \WC_Product $product )umami_wc_before_add_to_cart( array $data, \WC_Product $product )umami_wc_before_remove_from_cart( array $data, \WC_Product $product )umami_wc_before_view_cart( array $data )umami_wc_before_begin_checkout( array $data )umami_wc_before_purchase( array $data, \WC_Order $order )
add_filter( 'umami_wc_event_data', function ( array $data, string $event ): array {
$data['site_lang'] = get_locale();
return $data;
}, 10, 2 );add_filter( 'umami_wc_event_enabled', function ( bool $enabled ): bool {
if ( current_user_can( 'manage_options' ) ) {
return false;
}
return $enabled;
} );- The Umami
<script>tag is enqueued viawp_enqueue_scriptswith a proper handle, so page-cache plugins will include it in the cached HTML. - AJAX add-to-cart events are tracked purely client-side, bypassing page cache entirely.
- Server-side events (add to cart, remove from cart) are stored in the WC Session and flushed on the next non-cached page load, ensuring they survive redirects and fragment caches.
- The purchase event is gated by
_umami_wc_trackedorder meta to prevent duplicates on page refresh.
The plugin declares High-Performance Order Storage (HPOS / Custom Order Tables) compatibility via FeaturesUtil::declare_compatibility().
GPL-2.0-or-later