mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 08:08:43 +00:00
Add Google Analytics (GA4) with Consent Mode to footer.php: Implemented tracking script that respects user consent for analytics and marketing cookies, enhancing compliance with privacy regulations.
This commit is contained in:
@@ -121,6 +121,41 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Google Analytics (GA4) mit Consent Mode -->
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
|
||||||
|
// Standard: keine Analyse/Marketing-Cookies bis zur Einwilligung
|
||||||
|
gtag('consent', 'default', {
|
||||||
|
analytics_storage: 'denied',
|
||||||
|
ad_storage: 'denied',
|
||||||
|
ad_user_data: 'denied',
|
||||||
|
ad_personalization: 'denied'
|
||||||
|
});
|
||||||
|
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-EF0E9VPMTD', {
|
||||||
|
anonymize_ip: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Übergibt Consent-Änderungen aus dem eigenen Cookie-Banner an GA
|
||||||
|
window.addEventListener('cookieConsentUpdated', function (event) {
|
||||||
|
var payload = event && event.detail ? event.detail : {};
|
||||||
|
var consent = payload.consent ? payload.consent : payload;
|
||||||
|
var analyticsGranted = !!(consent && consent.analytics);
|
||||||
|
var marketingGranted = !!(consent && consent.marketing);
|
||||||
|
|
||||||
|
gtag('consent', 'update', {
|
||||||
|
analytics_storage: analyticsGranted ? 'granted' : 'denied',
|
||||||
|
ad_storage: marketingGranted ? 'granted' : 'denied',
|
||||||
|
ad_user_data: marketingGranted ? 'granted' : 'denied',
|
||||||
|
ad_personalization: marketingGranted ? 'granted' : 'denied'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-EF0E9VPMTD"></script>
|
||||||
|
|
||||||
<script src="/assets/js/main.js" defer></script>
|
<script src="/assets/js/main.js" defer></script>
|
||||||
<script src="/assets/js/cookie-consent.js" defer></script>
|
<script src="/assets/js/cookie-consent.js" defer></script>
|
||||||
<?php if (isset($additional_scripts)): ?>
|
<?php if (isset($additional_scripts)): ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user