Skip to content

Configuration

MikroAnalytics uses MikroConf. The primary configuration file is mikroanalytics.config.json; environment variables and CLI flags are intended for deployment-specific overrides such as secrets, host, and port.

Sites and analytics origins are managed in the dashboard, not in the configuration file.

Use MIKROANALYTICS_CONFIG_PATH to point to a different config file.

Configuration precedence is:

  1. CLI flags.
  2. Environment variable overrides.
  3. mikroanalytics.config.json.
  4. Built-in defaults.
{
"appUrl": "https://analytics.example.com",
"host": "127.0.0.1",
"port": 3000,
"staticRoot": "/opt/mikroanalytics/app/current",
"admin": {
"token": "replace-with-a-long-random-token"
},
"auth": {
"enabled": true,
"allowedEmails": ["[email protected]"],
"allowedDomains": [],
"jwtSecret": "replace-with-at-least-32-random-characters",
"magicLinkExpirySeconds": 900,
"jwtExpirySeconds": 3600,
"refreshTokenExpirySeconds": 604800,
"maxActiveSessions": 3
},
"email": {
"emailSubject": "Sign in to MikroAnalytics",
"host": "smtp.example.com",
"user": "smtp-user",
"password": "smtp-password",
"port": 587,
"secure": false,
"maxRetries": 2,
"debug": false
},
"privacy": {
"aggregateRetentionDays": 395,
"collectUniqueVisitors": false,
"honorDoNotTrack": true,
"storeRawEvents": false,
"rawEventRetentionHours": 24,
"referrerPolicy": "origin",
"geo": {
"enabled": false,
"countryHeader": "cf-ipcountry"
}
}
}
FieldDefaultPurpose
appUrlhttp://127.0.0.1:3000Public dashboard URL used by auth and secure-cookie detection.
host127.0.0.1Interface the Node server binds to.
port3000Port the Node server listens on.
staticRootdist/publicDirectory containing the static dashboard and tracker app.
admin.tokenemptyBearer token for protected API automation.

Sites are stored in SQLite and managed from the dashboard. Use the dashboard to create a site, set allowed origins, and copy the tracker snippet.

FieldDefaultPurpose
aggregateRetentionDays395Number of days to keep aggregate rows.
collectUniqueVisitorsfalseEnables daily unique estimates. Requires a salt.
uniqueVisitorSaltemptySecret used for daily unique hashing.
honorDoNotTracktrueIgnores collection when DNT or GPC is present.
storeRawEventsfalseStores short-lived sanitized raw debug records.
rawEventRetentionHours24Retention for raw debug records when enabled.
referrerPolicyoriginorigin, same-origin-path, or none.
trustProxyfalseReads forwarded IP headers for unique estimates.
geo.enabledfalseReads country code from a request header.
geo.countryHeadercf-ipcountryHeader used for country code collection.
VariablePurpose
MIKROANALYTICS_CONFIG_PATHConfig file path.
MIKROANALYTICS_APP_URLPublic dashboard URL.
MIKROANALYTICS_HOSTServer bind host.
MIKROANALYTICS_PORTServer port.
MIKROANALYTICS_STATIC_ROOTStatic dashboard and tracker directory.
MIKROANALYTICS_ADMIN_TOKENBearer token for protected API calls.
MIKROANALYTICS_AUTH_ENABLEDEnables MikroAuth.
MIKROANALYTICS_AUTH_ALLOWED_EMAILSComma-separated allowed emails.
MIKROANALYTICS_AUTH_ALLOWED_DOMAINSComma-separated allowed domains.
MIKROANALYTICS_AUTH_JWT_SECRETDashboard session signing secret.
MIKROANALYTICS_EMAIL_HOSTSMTP host.
MIKROANALYTICS_EMAIL_USERSMTP user.
MIKROANALYTICS_EMAIL_PASSWORDSMTP password.
MIKROANALYTICS_AGGREGATE_RETENTION_DAYSAggregate retention override.
MIKROANALYTICS_COLLECT_UNIQUE_VISITORSEnables daily unique estimates.
MIKROANALYTICS_UNIQUE_SALTSecret salt for daily unique estimates.
MIKROANALYTICS_STORE_RAW_EVENTSEnables raw debug records.
MIKROANALYTICS_TRUST_PROXYReads forwarded IP headers.
FlagPurpose
--config, --config-pathConfig file path.
--app-urlPublic dashboard URL.
--hostServer bind host.
--portServer port.
--static-rootStatic dashboard and tracker directory.
--admin-tokenBearer token for protected API calls.
--auth-enabledEnables MikroAuth.
--auth-allowed-emailsComma-separated allowed emails.
--auth-allowed-domainsComma-separated allowed domains.
--auth-jwt-secretDashboard session signing secret.
--email-host, --email-user, --email-passwordSMTP settings.
--collect-unique-visitorsEnables daily unique estimates.
--unique-saltSecret salt for daily unique estimates.
--store-raw-eventsEnables raw debug records.
--trust-proxyReads forwarded IP headers.