Skip to main content

WooCommerce Analytics

WooCommerce Analytics provides powerful reporting and insights for your store. This guide shows you how to extend analytics reports, add custom columns, modify SQL queries, and create custom tracking.

Overview

The analytics system in WooCommerce provides:
  • Pre-built reports for orders, products, customers, and more
  • Extensible data stores using custom database tables
  • JavaScript hooks for UI customization
  • PHP filters for modifying queries and data
  • REST API endpoints for accessing report data
WooCommerce Analytics uses dedicated database tables (with wc_ prefix) for optimized query performance, separate from WordPress core tables.

Extending Analytics Reports

Adding a Custom Filter

Add UI filters to reports to allow merchants to segment data:

Handling Filter Parameters

Process the filter parameter on the backend:

Modifying SQL Queries

Extend the SQL queries to filter data:

Adding Columns to Reports

Add custom columns to analytics tables:

Custom Currency Formatting

Modify how currencies are displayed in reports:

Adding Custom Report Sections

Register custom analytics sections and pages:

Custom Analytics Data Store

Create a custom data store for advanced analytics:

Tracking Custom Events

Track custom analytics events:

REST API Integration

Access analytics data via REST API:

Available Hooks

JavaScript Hooks

PHP Hooks

Database Tables

WooCommerce Analytics uses these main tables:
  • wp_wc_order_stats - Order statistics
  • wp_wc_order_product_lookup - Product order data
  • wp_wc_order_tax_lookup - Tax data
  • wp_wc_order_coupon_lookup - Coupon usage
  • wp_wc_customer_lookup - Customer data

Performance Optimization

Best practices for analytics performance:
  • Use prepared statements for all database queries
  • Add appropriate indexes to custom tables
  • Cache expensive queries using transients
  • Batch process large data imports
  • Use Action Scheduler for background processing
  • Limit date ranges in queries

Testing Analytics Extensions

1

Generate Test Data

Use WooCommerce’s built-in test data generators or create sample orders programmatically.
2

Test Filters

Verify UI filters appear correctly and query parameters are passed.
3

Validate SQL

Enable query logging to verify SQL modifications work correctly:
4

Check Performance

Use Query Monitor plugin to identify slow queries.

Common Use Cases

Product Performance Tracking

Track which products perform best:

Customer Lifetime Value

Calculate customer lifetime value: