Script checks before rendering

This commit is contained in:
Alex Tselegidis 2023-02-21 08:11:14 +01:00
parent 01d03f50a6
commit c9715d7431
2 changed files with 4 additions and 3 deletions

View file

@ -4,7 +4,7 @@
*/ */
?> ?>
<?php if (substr($google_analytics_code, 0, 2) === 'UA'): ?> <?php if (substr($google_analytics_code ?? '', 0, 2) === 'UA'): ?>
<script> <script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@ -15,7 +15,7 @@
</script> </script>
<?php endif ?> <?php endif ?>
<?php if (substr($google_analytics_code, 0, 2) === 'G-'): ?> <?php if (substr($google_analytics_code ?? '', 0, 2) === 'G-'): ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=' . $google_analytics_code . '"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=' . $google_analytics_code . '"></script>
<script> <script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];

View file

@ -23,7 +23,8 @@
})(); })();
</script> </script>
<noscript><p><img src="<?= $matomo_analytics_url ?>matomo.php?idsite=1&amp;rec=1" style="border:0;" alt=""/></p> <noscript>
<p><img src="<?= $matomo_analytics_url ?>matomo.php?idsite=1&amp;rec=1" style="border:0;" alt=""/></p>
</noscript> </noscript>
<?php endif ?> <?php endif ?>