Skip to content

Reporting & Analytics

Flow ID: AD-10 Module(s): eshop Complexity: High Last Updated: 2026-04-04

Business Context

The reporting system provides 20+ reports across orders, vendors, products, categories, customers, geography, shipping, and payments. Reports support date-range filtering with 7 timespan options (day/week/15-day/month/quarter/semester/year) and Chart.js visualizations. A live dashboard provides real-time KPIs with optional Matomo visitor data and AI recommendation tracking.

Entry Points

TypePath / TriggerControllerMethod
AdminReportsecommercen/eshop/controllers/Adv_reporting.phpVarious (20+ methods)
AdminDashboard APIsamedashboardLive() (JSON)
RolesRequiredAUTH_ROLE_ADVISABLE, AUTH_ROLE_ADMIN, or AUTH_ROLE_REPORTING

Report Categories

Timeseries Reports (date-ranged, with charts):

ReportMethodData SourceExport
Ordersorders()getOrderDataGroupedDay/Month/Year()Chart
Order Bundlesorders_bundles()getOrderBundleDataGroupedByTimespanSelector()Chart
Vendor Salesvendors_timespans()getVendorDataGroupedDay/Month/Year()Chart
Vendor Productsvendor_products_timespans()Vendor + product breakdownChart
Productsproducts_timespans()getProductDataGroupedDay/Month/Year()Chart
Categoriescategories_timespans()Category breakdownChart
Payment Methodspayways()getPaywaysDataGroupedDay/Month/Year()Chart
Online/Offlineonoffline()By webignore flagChart

Customer Reports: New customers, top spenders, top ranking (cached), new vs returning ratio.

Geographic Reports: By referrer source, country, county, marketplace.

Logistics: By shipping method, free shipping orders.

Special: Product search with CSV export, MVPs (most valuable products — first-added-to-cart analysis).

Dashboard Widgets

Live JSON endpoint dashboardLive() provides:

  • Hour/day/month order metrics (total VAT, count, items, avg cart)
  • Guest vs registered customer breakdown
  • New vs returning customer ratio
  • Vendor/category/product performance tables
  • Shipping method breakdown
  • Payment method breakdown
  • Cart value range distribution
  • Weight-based order analysis
  • Optional: Matomo live visitors/visits/CVR
  • Optional: AI recommendation revenue tracking

Reporting Engine Details

Adv_reporting.php contains 30+ reporting methods, making it one of the largest controllers in the application.

7 timespan granularities: 1 day, 7 days, 15 days, 1 month, 3 months, 6 months, 1 year. All timeseries reports support all granularities via a shared timespan selector.

Dashboard live metrics (dashboardLive()): 20+ real-time KPIs refreshed on each admin dashboard load, including hourly/daily/monthly order totals, guest vs registered breakdown, new vs returning ratio, vendor/category/product performance, shipping/payment method distribution, cart value ranges, and weight-based analysis.

Databox Integration

15 Databox metrics are pushed every 30 minutes via a scheduled job:

#MetricDescription
1RevenueTotal order revenue (VAT-inclusive)
2OrdersOrder count
3QuantityTotal items sold
4AOVAverage order value
5RegistrationsNew customer registrations
6CustomersUnique purchasing customers
7Order MethodBreakdown by online/offline/phone
8Payment MethodBreakdown by payment gateway
9Shipping CostTotal shipping revenue
10TransportersOrders per shipping provider
11StoresOrders per pickup store
12Referrer CostRevenue attributed by referrer source
13MarketplacesOrders from marketplace channels
14CountryOrders by country
15CountyOrders by county/region

Analytics Tracking

Matomo server-side tracking: Matomo integration includes a circuit breaker to prevent cascading failures when the Matomo server is unavailable. Visitor data and conversion rates are conditionally displayed on the admin dashboard.

GA4 tracking: Google Analytics 4 event tracking functions are provided by tracking_helper.php, used for e-commerce event dispatch (purchase, add_to_cart, view_item, etc.) on the storefront.

Business Rules

RuleDescription
Excluded statusesAll order reports exclude CANCELED, PENDING, RETURN
7 timespan optionsday, week, 15-day, month, quarter, semester, year
CSV exportSpecial products and MVPs support semicolon-delimited UTF-8 BOM CSV
Matomo integrationConditional on MATOMO::ENABLED + MATOMO::SHOW_ADMIN_DASHBOARD registry
Matomo circuit breakerServer-side Matomo calls are protected by circuit breaker to avoid dashboard slowdowns
AI trackingConditional on ADVISABLE_AI::ENABLED + ADVISABLE_AI::SHOW_ADMIN_DASHBOARD
Top ranking cachedgetTopRankingCustomers() uses PSCache
Databox push intervalEvery 30 minutes via scheduled job

Domain Layer

Controller: Adv_reporting.php (3,439 lines)

The reporting controller is one of the largest in the application. It extends Admin_c and requires AUTH_ROLE_ADVISABLE, AUTH_ROLE_ADMIN, or AUTH_ROLE_REPORTING.

Models loaded: order_model, vendors_model, product_category_model, customer_model, reporting_model.

Complete Method Reference

Timeseries Reports (date-ranged, chart-rendered):

MethodLinesDescriptionGranularity
orders()71-147Order revenue/count by timespanDay/Month/Year
orders_bundles()149-191Bundle order data by timespanDay/Month/Year
vendors_timespans()327-426Vendor revenue/count breakdownDay/Month/Year
vendor_products_timespans()427-512Vendor + product cross-breakdownDay/Month/Year
products_timespans()513-595Product-level revenue/countDay/Month/Year
categories_timespans()596-672Category breakdownDay/Month/Year
categories_products_timespans()673-748Category + product cross-breakdownDay/Month/Year
payways()749-811Payment method breakdownDay/Month/Year
onoffline()812-874Online vs offline (phone) ordersDay/Month/Year

AJAX Chart Data Reports (loaded via admin JS scripts):

MethodDescription
vendors()Vendor report page (AJAX-loaded chart)
products()Product report page (AJAX-loaded chart)
vendor_products()Vendor-product report page
categories()Category report page
categories_products()Category-product report page
productInOrders()Product-in-orders lookup

Customer Reports:

MethodDescription
new_customers()New customer registrations in date range
top_customers()Top customers by spend in date range
topRankingCustomers()All-time top customers (PSCache-cached)
newCustomersRatio()New vs returning customer ratio

Geographic Reports:

MethodDescription
referrer()Orders by referrer source (Skroutz, Google, direct, etc.)
marketplace()Orders by marketplace provider
countries()Orders by country
counties()Orders by county/region

Logistics Reports:

MethodDescription
shipping()Orders by shipping method/transporter
freeShipping()Free shipping order analysis

Special Reports:

MethodDescriptionExport
specialProducts()Product search with advanced filtersCSV (semicolon, UTF-8 BOM)
mvps()Most Valuable Products -- first-added-to-cart analysisCSV

Dashboard:

MethodDescription
dashboardLive()JSON API for real-time admin dashboard

Dashboard Live JSON Structure

The dashboardLive() method returns a structured JSON response consumed by the Vue.js admin dashboard. It assembles data from 11 sub-report generators:

dashboardLive() JSON response
├── general
│   ├── statsHeader (localized label)
│   └── customHeader (localized label)
├── tabs[] (hour/day/month data sets)
├── quickViews[] (summary KPIs per timeframe)
│   ├── totalVat, ordersCount, itemsCount, avgCartValue
│   ├── guestCustomers, registeredCustomers
│   ├── newCustomers, oldCustomers
│   ├── Smart recommendation revenue (if SMART_RECOMMENDATIONS enabled)
│   └── AI recommendation revenue (if ADVISABLE_AI enabled)
├── nodes[] (detailed breakdowns)
│   ├── cartOrders (cart value distribution)
│   ├── weightOrders (weight-based distribution)
│   ├── deliveryOrders (delivery time distribution)
│   ├── onlineOfflineOrders (channel breakdown)
│   ├── brandOrders (vendor performance: totalVat/items/orders)
│   ├── categoriesOrders (category performance)
│   ├── productsOrders (product performance)
│   ├── shippingReport (transporter + store breakdown)
│   └── paymentReport (payment method breakdown)
├── customViews[]
│   └── inProcess (orders in process count)

Three timeframes computed: Last hour, today (day), and current month. Each generates a separate quickView entry with trend calculations via calculateTrend().

Conditional features in dashboard:

  • SMART_RECOMMENDATIONS.IS_ENABLED_BASED_ON_CART -- adds smart recommendation revenue tracking
  • ADVISABLE_AI.ENABLED -- adds AI recommendation revenue tracking
  • Matomo visitor data (handled separately by admin Vue dashboard, not in this JSON)

Databox Integration (Deep)

Library: ecommercen/libraries/AdvDatabox.php (964 lines)

Job: ecommercen/job/libraries/AdvReportingToDatabox.php -- implements JobCommand, triggered via CLI:

bash
php cli.php job/ReportingToDatabox/all        # Push all 15 metrics (3-month window)
php cli.php job/ReportingToDatabox/all/1      # Push all 15 metrics (full 3-year history)
php cli.php job/ReportingToDatabox/sentRevenue # Push single metric

Configuration: Enabled via DATABOX.ENABLED registry. Token stored encrypted in DATABOX.TOKEN.

Push mechanism: HTTP POST to https://push.databox.com/data with Basic Auth (token as username). Data is chunked into batches of 500 rows. Rate-limited: every 10th API call triggers a 1-second sleep to avoid rate limiting.

SQL query pattern: All 15 metrics use the same query structure:

  • Filter: status NOT IN ('CANCELED', 'RETURN', 'PENDING')
  • Granularity: Hourly (DATE_FORMAT(entry_datetime, '%Y-%m-%d %H:00:00'))
  • Time window: Last 3 months (recurring) or last 3 years (initialization)
  • Each row maps to a Databox data point with key, value, date, optional unit, and attributes

Detailed metric SQL sources:

#Metric KeySQL SourceAttributes
1RevenueSUM(total_vat) + SUM(total) from shop_ordervat: With Vat / No Vat, unit: EUR
2OrdersCOUNT(shop_order.id)--
3QuantitySUM(shop_order_basket.qty) excluding gifts--
4Average Order ValueROUND(AVG(total_vat), 2)unit: EUR
5RegistrationsCOUNT(shop_customer.id) where is_guest=0--
6CustomersCOUNT(shop_customer.id) joined via shop_orderregistration: Registered / No registered
7Order MethodCOUNT grouped by webignoremethod: By phone / On line
8Payment MethodCOUNT grouped by paywaymethod: {payway value}
9Shipping CostCOUNT grouped by transportation_cost > 0cost: Paid / Free
10Shipping typeCOUNT grouped by transport_idtransporter: {name from transporters_mui}
11Picking pointCOUNT grouped by store_idstore: {address from store_mui}
12ReferrerCOUNT grouped by skroutz_refererchannel: {from referrerChannels config}
13MarketplacesCOUNT grouped by providerchanel: {from marketPlaces config}
14CountryCOUNT grouped by pricing_countrycountry: {from country table}
15CountyCOUNT grouped by pricing_countycounty: {from county table}, unit: count

GA4 / Tracking Helper

File: ecommercen/helpers/tracking_helper.php

Provides server-side GA4 event functions for storefront e-commerce tracking. These are NOT part of the admin reporting controller but generate the data layer that GA4 uses. Events include: purchase, add_to_cart, remove_from_cart, view_item, view_item_list, begin_checkout, etc.

Matomo Admin Dashboard Integration

Matomo visitor data is conditionally displayed on the admin dashboard when:

  • MATOMO.ENABLED registry value is truthy
  • MATOMO.SHOW_ADMIN_DASHBOARD registry value is truthy

The integration uses a circuit breaker pattern (see SY-26 Circuit Breaker) to prevent cascading failures when the Matomo server is unavailable. Matomo data includes:

  • Live visitor count
  • Visit count for the day
  • Conversion rate (CVR)

Configuration stored encrypted in registry: MATOMO.TOKEN, MATOMO.SITE_ID, with MATOMO.SITE_URL, MATOMO.TIMEOUT, MATOMO.CONNECT_TIMEOUT for HTTP client tuning.

Chart Rendering Architecture

All timeseries reports use a shared graph-setting infrastructure. Each report type has dedicated graph methods:

Graph CategorySet MethodsRendering
General (orders)setGeneralHourReportGraph, setGeneralDaysReportGraph, setGeneralMonthsReportGraphLine/bar charts
CustomerssetCustomersGraphsPie/bar for guest/registered/new/returning
ShippingsetShippingGraphsBar for transporter + store distribution
PaymentsetPaymentGraphsPie for payment method split
Cart valuesetCartGraphsHistogram for cart value ranges
WeightsetWeightGraphsHistogram for order weight distribution
DeliverysetDeliveryGraphsDelivery time distribution
Online/OfflinesetOnlineOfflineGraphsPie/bar for channel
Brand (vendor)setBrandTotalVatGraphs, setBrandItemsGraphs, setBrandOrdersGraphsThree metrics per vendor
CategorysetCategoriesTotalVatGraphs, setCategoriesItemsGraphs, setCategoriesOrdersGraphsThree metrics per category
ProductsetProductsTotalVatGraphs, setProductsItemsGraphs, setProductsOrdersGraphsThree metrics per product

Colors are pre-defined as RGBA values in the constructor and cycled through datasets.