Analytics
The Analytics page collects store statistics and presents them in the Control Panel. Access is consent-gated: an admin must explicitly enable data collection before the dashboard is visible.
Navigate to yStore → Analytics.
Enabling analytics
The first time you visit the Analytics page, yStore checks whether consent has been granted (analyticsConsentGiven plugin setting). If consent has not been given, access is blocked with a notice directing you to enable it from Plugin Settings.
To enable:
- Go to
yStore → Settings → Plugin. - Find the Analytics section and enable data collection.
- Save the settings.
- Navigate to
yStore → Analytics— the statistics dashboard is now accessible.
Consent can be revoked at any time from the same Plugin Settings page. Revoking consent prevents the analytics dashboard from loading and stops new data collection.
What the dashboard shows
The analytics dashboard displays store-wide statistics derived from live database queries. The data is organized into sections, each populated by an analytics.xml definition file. Sections can include:
- General store information (site name, currency, Craft version, PHP version, installed plugins)
- Plugin settings snapshot
- Statistical aggregates from order, product, and customer tables
The exact metrics available depend on the analytics.xml files shipped with each yStore plugin. Each file contributes named table sections that appear as cards or groups on the dashboard.
Exporting analytics data
The Download action on the Analytics page collects statistics and plugin logs, encrypts them, and compresses them into .gz files available for download. These files are intended for sharing with yStore support when troubleshooting.
The download process:
- Statistics are collected and encrypted with AES-256-CBC using the store's configured
encryptionKeyandencryptionIvvalues (Plugin Settings → API Credentials). - Plugin logs are encrypted and compressed separately.
- Both files are offered as downloads. After download, the compressed files are deleted from the server.
The encryption key and IV are included as metadata in the download response so that the recipient (yStore support) can decrypt the data. Treat downloaded analytics files as confidential.
Consent model
| State | Effect |
|---|---|
| Not set (default) | Dashboard blocked; download endpoint returns no data |
| Consent granted | Dashboard accessible; download creates encrypted files |
| Consent revoked | Dashboard blocked; analyticsConsentGiven = null is persisted |
Developer reference
Service
yui\craft\services\AnalyticsService (access via Plugin::getInstance()->getAnalytics())
| Method | Description |
|---|---|
collectStatistics() | Scan vendor analytics.xml files, run queries, populate the data array. Returns $this for chaining. |
getCollectedData() | Return the populated statistics array |
encryptData($data) | AES-256-CBC encrypt a string or array using the store's key/IV |
saveToFile($encryptedData, $compress, $filename) | Write and optionally gzip-compress encrypted data to storage/yui/ |
getCompressedFilePath($filename) | Return the path to an existing .gz file, or null |
getPlugins($onlyYuiMade, $licenses) | Return an array of installed plugin metadata |
Analytics XML definition format
Any plugin can contribute analytics data by placing an analytics.xml file in its vendor directory. The service recursively scans @vendor/yui for files named analytics.xml.
Basic structure:
<analytics>
<table name="yui_orders" code="orders_statistics">
<columns>
<column name="total_orders" type="count" target="entity_id"/>
<column name="total_revenue" type="sum" target="grand_total"/>
<column name="avg_order_value" type="avg" target="grand_total"/>
</columns>
</table>
</analytics>
| Attribute | Description |
|---|---|
table[@name] | Database table name (without prefix) |
table[@code] | Key under which the result is stored in the data array |
column[@type] | Aggregation type: count, sum, avg, or omit for a plain column |
column[@target] | Column to aggregate (comma-separate multiple for multi-column sums) |
column[@expression] | Raw SQL expression to use instead of a typed column |
When table[@code] contains the string statistics, the result is stored as a single row (aggregates). Otherwise it is stored as {total, items}.
Add optional <condition>, <order>, <group>, and <join> child elements to filter or join data:
<table name="yui_orders" code="recent_orders">
<columns>
<column name="increment_id"/>
<column name="grand_total"/>
</columns>
<condition logic="and">
<rule column="order_id" operator="isNotNull"/>
</condition>
<order column="dateCreated" direction="DESC"/>
</table>
Supported condition operators: isNotNull, isNull, greaterThan, lessThan, =.
Controller actions
yui\craft\controllers\AnalyticsController
| Action | Route | Description |
|---|---|---|
actionIndex | GET yui/analytics | Render the analytics dashboard (requires consent) |
actionSaveConsent | POST yui/analytics/save-consent | Save or revoke consent (consent: true/false/null) |
actionDownload | GET yui/analytics/download | Collect, encrypt, compress, and return analytics + log files |