Configuration
You can customise Metrix’s settings using a PHP configuration file. This is optional: each setting has a default, so you only need to include the values you want to change.
To override a setting, create metrix.php in your Craft project’s /config directory and return an array of setting names and values. For example, the following will set the real-time refresh interval to 20 seconds:
<?php
return [
'realtimeInterval' => 20,
];All other settings keep their defaults. Add any further settings you want to change to the same array. The options below explain the available settings and their defaults.
Values in config/metrix.php override the corresponding values saved in the control panel. To manage a setting through the control panel again, remove its override from the file.
Environment Overrides
Craft can apply different settings to each environment. Use * for shared values and a key matching CRAFT_ENVIRONMENT for an environment-specific override. For example:
<?php
return [
'*' => [
'realtimeInterval' => 20,
],
'dev' => [
'realtimeInterval' => 60,
],
];This replaces the simple array above. The dev values apply only when CRAFT_ENVIRONMENT is dev; other environments use the shared values. Merge your own overrides into the appropriate array.
Configuration Options
Type: string · Default: 'Metrix'
The name of the plugin as it appears in the Control Panel.
Type: bool · Default: true
Whether to enable Metrix in the main sidebar navigation.
Type: bool · Default: true
Whether to cache API requests.
Type: string · Default: 'PT10M'
The cache duration for API requests as an ISO 8601 duration string (opens new window), such as PT10M for ten minutes or PT1H for one hour.
Type: array · Default: []
Exact hostnames which may resolve to private or otherwise non-public IP addresses for self-hosted GoatCounter, Matomo, Plausible or Umami instances. Keep this list in config/metrix.php so only trusted configuration operators can approve internal network destinations. Do not include a scheme, port or path.
Requests to these configurable provider URLs bypass Craft’s global httpProxy setting so the validated DNS answers can remain pinned to the connection.
return [
'allowedPrivateProviderHosts' => [
'analytics.internal.example',
],
];Publicly routable self-hosted hosts do not need to be listed. Provider URLs are otherwise limited to HTTP or HTTPS public destinations and cannot follow redirects.
Type: int · Default: 10
The number of seconds between requests from Realtime widgets, from 1 to 2147483. Values must be whole numbers within the browser timer’s supported range. Increase this interval when less frequent updates are sufficient or when you need to reduce requests to the provider.
Type: array · Default: []
Default configuration for new widgets. When empty, Metrix uses a Line widget with inheritPeriod set to true and width 1.
Type: array|string · Default: '*'
Choose which chart types editors can create. Use '*' for all registered types, or an array of Widget class names. For example, allow counters and line charts in config/metrix.php:
return [
'enabledWidgetTypes' => [
\verbb\metrix\widgets\Counter::class,
\verbb\metrix\widgets\Line::class,
],
];Add the setting to your existing configuration array, then open the new-widget form and check the chart-type choices.
Type: array · Default: []
Choose which date ranges appear and how they are grouped. Supply an array of groups, with Period class names inside each group. For example:
return [
'enabledPeriods' => [
[
\verbb\metrix\periods\Today::class,
\verbb\metrix\periods\Yesterday::class,
],
[
\verbb\metrix\periods\Last7Days::class,
\verbb\metrix\periods\Last30Days::class,
],
],
];This puts the two individual days in one group and the longer ranges in another. It overrides periodSettings when non-empty. Leave it empty to use the control-panel period settings, or all registered periods when neither setting is configured. Check the dashboard date-range menu after changing it.
Type: array · Default: []
The period order and enabled state saved by the control panel. Use enabledPeriods for a shorter PHP configuration, or supply rows with exact id and enabled keys when you need the same format as the control panel:
return [
'periodSettings' => [
['id' => \verbb\metrix\periods\Last7Days::class, 'enabled' => true],
['id' => \verbb\metrix\periods\Last30Days::class, 'enabled' => true],
],
];Unlisted periods are hidden when rows are supplied. A non-empty enabledPeriods value takes precedence over these rows.
Control Panel
You can also manage configuration settings through the Control Panel by visiting Settings → Metrix.