WooCommerce Metrics
WordPress WooCommerce Metric Collection Sales Analytics Customer Product Google Analytics GA4 GTM Dashboard Looker Studio Revenue AOV CLV Conversion
| Metric | Formula | Target | Frequency | Source |
|---|---|---|---|---|
| Revenue | Sum of order totals | Growth 10%/month | Daily | WooCommerce |
| AOV | Revenue / Orders | > 1,500 THB | Weekly | WooCommerce |
| Conversion Rate | Orders / Visitors | > 2% | Daily | GA4 |
| Cart Abandon | 1 - (Purchases / Add to Cart) | < 70% | Weekly | GA4 |
| CLV | AOV × Purchase Freq × Lifespan | > 10,000 THB | Monthly | Custom Query |
| Repeat Rate | Returning Customers / Total | > 30% | Monthly | WooCommerce |
WooCommerce REST API
# === WooCommerce REST API Metrics ===
# pip install woocommerce
# from woocommerce import API
#
# wcapi = API(
# url="https://myshop.com",
# consumer_key="ck_xxxx",
# consumer_secret="cs_xxxx",
# version="wc/v3"
# )
#
# # Get orders
# orders = wcapi.get("orders", params={
# "per_page": 100,
# "after": "2024-01-01T00:00:00",
# "status": "completed"
# }).json()
#
# # Get products
# products = wcapi.get("products", params={
# "per_page": 100,
# "orderby": "popularity"
# }).json()
#
# # Get sales report
# sales = wcapi.get("reports/sales", params={
# "date_min": "2024-01-01",
# "date_max": "2024-12-31"
# }).json()
from dataclasses import dataclass
import numpy as np
@dataclass
class DailyMetric:
date: str
revenue: float
orders: int
visitors: int
new_customers: int
returning_customers: int
metrics = [
DailyMetric("2024-01-01", 45000, 28, 1200, 22, 6),
DailyMetric("2024-01-02", 38000, 22, 980, 18, 4),
DailyMetric("2024-01-03", 52000, 35, 1500, 28, 7),
DailyMetric("2024-01-04", 41000, 25, 1100, 20, 5),
DailyMetric("2024-01-05", 68000, 42, 1800, 35, 7),
DailyMetric("2024-01-06", 72000, 48, 2200, 38, 10),
DailyMetric("2024-01-07", 55000, 33, 1400, 25, 8),
]
print("=== Daily Metrics ===")
total_rev = sum(m.revenue for m in metrics)
total_orders = sum(m.orders for m in metrics)
total_visitors = sum(m.visitors for m in metrics)
aov = total_rev / total_orders
conv_rate = (total_orders / total_visitors) * 100
for m in metrics:
daily_aov = m.revenue / m.orders if m.orders > 0 else 0
daily_conv = (m.orders / m.visitors) * 100 if m.visitors > 0 else 0
print(f" [{m.date}] Rev: {m.revenue:,.0f} | Orders: {m.orders} | AOV: {daily_aov:,.0f}")
print(f" Visitors: {m.visitors} | Conv: {daily_conv:.1f}% | New: {m.new_customers}")
print(f"\n Weekly Summary:")
print(f" Total Revenue: {total_rev:,.0f} THB")
print(f" Total Orders: {total_orders}")
print(f" AOV: {aov:,.0f} THB")
print(f" Conversion Rate: {conv_rate:.1f}%")
GA4 E-commerce Tracking
# === Google Analytics 4 E-commerce Events ===
# GTM Data Layer — View Item
# window.dataLayer = window.dataLayer || [];
# dataLayer.push({
# event: 'view_item',
# ecommerce: {
# currency: 'THB',
# value: 1500,
# items: [{
# item_id: 'SKU001',
# item_name: 'Product Name',
# item_category: 'Electronics',
# price: 1500,
# quantity: 1
# }]
# }
# });
#
# // Add to Cart
# dataLayer.push({
# event: 'add_to_cart',
# ecommerce: {
# currency: 'THB',
# value: 1500,
# items: [{ item_id: 'SKU001', item_name: 'Product', price: 1500, quantity: 1 }]
# }
# });
#
# // Purchase
# dataLayer.push({
# event: 'purchase',
# ecommerce: {
# transaction_id: 'T12345',
# value: 3000,
# currency: 'THB',
# shipping: 50,
# tax: 0,
# items: [
# { item_id: 'SKU001', item_name: 'Product A', price: 1500, quantity: 1 },
# { item_id: 'SKU002', item_name: 'Product B', price: 1500, quantity: 1 }
# ]
# }
# });
# WooCommerce functions.php — Auto push dataLayer
# add_action('woocommerce_thankyou', function($order_id) {
# $order = wc_get_order($order_id);
# $items = [];
# foreach ($order->get_items() as $item) {
# $product = $item->get_product();
# $items[] = [
# 'item_id' => $product->get_sku(),
# 'item_name' => $item->get_name(),
# 'price' => $item->get_total() / $item->get_quantity(),
# 'quantity' => $item->get_quantity(),
# ];
# }
# echo "";
# });
@dataclass
class FunnelStep:
step: str
users: int
drop_rate: str
action: str
funnel = [
FunnelStep("Page View", 10000, "-", "SEO, Ads bring traffic"),
FunnelStep("Product View", 4500, "55% drop", "Improve landing page"),
FunnelStep("Add to Cart", 1200, "73% drop", "Better CTA, reviews"),
FunnelStep("Begin Checkout", 600, "50% drop", "Simplify checkout"),
FunnelStep("Purchase", 280, "53% drop", "Trust badges, payment options"),
]
print("\n=== Purchase Funnel ===")
for f in funnel:
conv = (f.users / 10000) * 100
print(f" [{f.step}] Users: {f.users:,} | Drop: {f.drop_rate} | Overall: {conv:.1f}%")
print(f" Improve: {f.action}")
Dashboard and Optimization
# === Custom Dashboard KPIs ===
@dataclass
class KPIDashboard:
kpi: str
current: str
target: str
trend: str
action: str
kpis = [
KPIDashboard("Monthly Revenue", "1.2M THB", "1.5M THB", "↑ +8%", "Increase AOV with bundles"),
KPIDashboard("AOV", "1,420 THB", "1,600 THB", "↑ +3%", "Add upsell cross-sell"),
KPIDashboard("Conversion Rate", "2.8%", "3.5%", "→ stable", "A/B test checkout flow"),
KPIDashboard("Cart Abandonment", "72%", "< 65%", "↓ -2%", "Add exit-intent popup"),
KPIDashboard("Repeat Purchase", "28%", "> 35%", "↑ +2%", "Email automation loyalty"),
KPIDashboard("CLV", "8,500 THB", "> 12,000 THB", "↑ +5%", "Retention campaigns"),
KPIDashboard("Page Speed", "3.2s", "< 2.5s", "→ stable", "Image optimization CDN"),
KPIDashboard("SEO Organic", "45% traffic", "> 55%", "↑ +3%", "Content marketing blog"),
]
print("Dashboard KPIs:")
for k in kpis:
print(f" [{k.kpi}] Current: {k.current} | Target: {k.target} | Trend: {k.trend}")
print(f" Action: {k.action}")
# Optimization Priorities
priorities = {
"P0 — This Week": "Fix slow checkout page (3.2s → 2s), add trust badges",
"P1 — This Month": "Implement cart abandonment email sequence (3 emails)",
"P1 — This Month": "Add product recommendation engine (upsell/cross-sell)",
"P2 — Next Month": "Launch loyalty program (points system)",
"P2 — Next Month": "SEO content plan (4 blog posts/month)",
"P3 — Quarter": "Migrate to headless WooCommerce + Next.js frontend",
}
print(f"\n\nOptimization Roadmap:")
for k, v in priorities.items():
print(f" [{k}]: {v}")
เคล็ดลับ
- GA4: ติดตั้ง GA4 E-commerce Tracking ทุก Event ตั้งแต่วันแรก
- GTM: ใช้ Google Tag Manager จัดการ Tags ทั้งหมดที่เดียว
- Funnel: วิเคราะห์ Purchase Funnel หา Drop-off Point
- AOV: เพิ่ม AOV ด้วย Bundle Upsell Cross-sell Free Shipping Threshold
- Email: ตั้ง Cart Abandonment Email อัตโนมัติ กู้คืน 10-15% ของ Cart
WooCommerce Metrics สำคัญมีอะไรบ้าง
Revenue AOV Orders Customer CLV Repeat Rate Churn Product Conversion Cart Abandonment Traffic Source ROI Marketing Stock Level
เก็บ Metrics อย่างไร
WooCommerce Analytics GA4 E-commerce GTM Tags REST API Plugin Metorik MonsterInsights SQL Query BigQuery Looker Studio Dashboard
ตั้ง Google Analytics 4 อย่างไร
GA4 Property GTM Plugin GTM4WP MonsterInsights Enhanced E-commerce view_item add_to_cart purchase Custom Dimensions Conversion Goals Report
สร้าง Custom Dashboard อย่างไร
Looker Studio GA4 WooCommerce API KPI Revenue Orders AOV Conversion Sales Trend Top Products Funnel Cart Abandonment Auto-refresh Email Report
สรุป
WordPress WooCommerce Metric Collection GA4 GTM REST API Revenue AOV CLV Conversion Funnel Cart Abandonment Dashboard Looker Studio Production Optimization
