Google Analytics verwendet als Tracking-Code nicht mehr die UA-xxxx, sondern eine Mess-ID G-xxxxx. Soweit ich das verstehe, ist die Mess-ID automatisch schon anonymisiert seitens Google.
Der Code seitens Google für die Einbindung im HEAD-Bereich schaut so hier aus:
HTML-Code:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-xxxxxxx"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-xxxxxxx');
</script>
Könnte man den einfach so im Seitenlayout mit übernehmen?
Das Template in analytics_google.html5 schaut so hier aus:
PHP-Code:
<?php
// To use this script, please fill in your Google Analytics ID below
$GoogleAnalyticsId = 'UA-XXXXX-X';
// DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
if ('UA-XXXXX-X' != $GoogleAnalyticsId && !BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?>
<script>
(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),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '<?= $GoogleAnalyticsId ?>', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
<?php endif; ?>
Kann man in diesem Template die UA in "$GoogleAnalyticsId = 'UA-XXXXX-X';" einfach mit der Mess-ID austauschen?
Lesezeichen