<?php if (!defined('MATOMO_SITE_ID')) return; ?>
<?php if (!defined('MATOMO_ENABLED') || !MATOMO_ENABLED) return; ?>
<?php
$primaryDomain = app_primary_domain();
$fakecheckDomain = app_fakecheck_domain();
$matomoDomains = array_values(array_unique(array_filter([
    $primaryDomain ? '*.' . $primaryDomain : null,
    ($fakecheckDomain && $fakecheckDomain !== $primaryDomain) ? '*.' . $fakecheckDomain : null,
])));
?>
<script type="application/json" id="matomoConfig"><?= json_encode([
    'url' => rtrim(MATOMO_URL, '/') . '/',
    'siteId' => (string) MATOMO_SITE_ID,
    'domains' => $matomoDomains,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?></script>
