Vielen Dank, Tim - wir versuchen das aus!
Ankündigung
Einklappen
Keine Ankündigung bisher.
Privacy Manager und Google Consent Mode V2
Einklappen
X
-
Hi Tim
Ich habe das Template eingebunden. Wenn ich das über die Developer-Console prüfe, scheint alles zu funktionieren. Allerdings meldet mir der Online-Marketer, dass bei ihnen im Google Tag Manager ein Fehler auftaucht: ERR_BLOCKED_BY_ORB. Ist doch irgendetwas an meinem Template falsch? Ich habe euer neustes analytics_google-Template als Grundlage genommen:
PHP-Code:<?php
global $objPage;
$objRoot = \Contao\PageModel::findByPk( $objPage->rootId );
/**
* To use this script, please fill in your Google Analytics ID below
*/
$GoogleAnalyticsId = $objRoot->analytics_google;
/**
* DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
*/
if ($GoogleAnalyticsId != 'GTM-XXXXXXXXXX' && !$this->hasAuthenticatedBackendUser()): ?>
<script id="analytics_<?= $GoogleAnalyticsId ?>"></script>
<script>
function initGoogleAnalytics()
{
document.getElementById('analytics_<?= $GoogleAnalyticsId ?>').src = 'https://www.googletagmanager.com/gtag/js?id=<?= $GoogleAnalyticsId ?>';
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true});
gtag("consent", "default",
{
ad_user_data: "denied",
ad_personalization: "denied",
ad_storage: "denied",
analytics_storage: "denied",
wait_for_update: 2000 // milliseconds to wait for update
});
// Enable ads data redaction by default [optional]
gtag("set", "ads_data_redaction", true);
}
// Optin privacy setting token
var token = localStorage.getItem('user_privacy_settings');
if( token == undefined )
{
token = '';
}
if(token.indexOf(1) >= 0)
{
initGoogleAnalytics();
}
// listen to privacy event
jQuery(document).on('Privacy.changed',function(eve nt,params)
{
if(params.level.indexOf(1) >= 0)
{
initGoogleAnalytics();
}
});
</script>
<?php endif; ?>
Kommentar
-
Wenn das Script ausgeführt wird, greift quasi nur noch Google. Ist es gewünscht, dass alles weiterhin auf "denied" steht. Das wäre meines Erachtens weiterhin die Mitteilung an Google, dass alles geblockt wird.
https://support.google.com/tagmanage...d-by-orb?hl=en
Kommentar
-
Hi Tim
Ich habe auf «granted» umgestellt. Für mich sieht irgendwie alles in Ordnung aus - beim Testing sehe ich in der Konsole den collect-Stream und den Parameter gcs:G111. An was könnte das liegen, dass da nichts bei Google ankommt? Hier zwei Screenshots aus der Developer-Console - hilft das?
Kommentar
-
Wenn das Script ausgeführt wird, greift Google. Ich kann auf Google Ebene keinen Support geben - das ist nicht mein Steckenpferd.
Kommentar
-
Hi Tim, hier noch als Nachtrag. Ich habe das analytics_googletagmanager-Template folgendermassen angepasst und so funktionierts:
PHP-Code:<?php
global $objPage;
$objRoot = \Contao\PageModel::findByPk( $objPage->rootId );
/**
* To use this script, please fill in your Google Analytics ID below
*/
$GoogleAnalyticsId = $objRoot->analytics_google;
/**
* DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
*/
if ($GoogleAnalyticsId != 'GTM-XXXXXXXXXX' && !BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?>
<script id="googletagmanager_<?= $GoogleAnalyticsId; ?>">
// Google Consent Mode
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true});
gtag("consent", "default",
{
ad_user_data: "denied",
ad_personalization: "denied",
ad_storage: "denied",
analytics_storage: "denied",
personalization_storage: "denied",
security_storage: "denied",
functionality_storage: "denied",
wait_for_update: 2000 // milliseconds to wait for update
});
// Enable ads data redaction by default [optional]
gtag("set", "ads_data_redaction", true);
// Optin privacy setting token
var token = localStorage.getItem('user_privacy_settings');
if( token == undefined )
{
token = '';
}
if(token.indexOf(3) >= 0)
{
gtag("consent", "update",
{
ad_user_data: "granted",
ad_personalization: "granted",
ad_storage: "granted",
analytics_storage: "granted",
personalization_storage: "granted",
security_storage: "granted",
functionality_storage: "granted"
});
}
// listen to privacy event
jQuery(document).on('Privacy.changed',function(eve nt,params)
{
if(params.level.indexOf(3) >= 0)
{
gtag("consent", "update",
{
ad_user_data: "granted",
ad_personalization: "granted",
ad_storage: "granted",
analytics_storage: "granted",
personalization_storage: "granted",
security_storage: "granted",
functionality_storage: "granted"
});
}
});
// Optin privacy setting token
if(token.indexOf(3) >= 0)
{
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<?= $GoogleAnalyticsId; ?>');
}
// listen to privacy event
jQuery(document).on('Privacy.changed',function(eve nt,params)
{
if(params.level.indexOf(3) >= 0)
{
//location.reload();
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<?= $GoogleAnalyticsId; ?>');
}
});
</script>
<?php endif; ?>
Kommentar
-
Ein Fehler ist im Google Tag Manager noch vorhanden:A tag read consent state before a default was set
Kommentar
-
Guten Tag,
die Ursache für die Fehlermeldung liegt vermutlich in der Reihenfolge beim Aufrufen von den Funktionen "gtag(...)"
Der Funktionsaufruf bei dem die Default-Einstellungen gesetzt werden, sollte zuerst ausgeführt werden.
Also zuerst:
Code:gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", personalization_storage: "denied", security_storage: "denied", functionality_storage: "denied", wait_for_update: 2000 // milliseconds to wait for update });
Code:gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true});
Das sollte den Fehler beheben.
Beste GrüßeZuletzt geändert von grobi; 21.06.2024, 19:23.
- 2 Likes
Kommentar
-
Zitat von grobi Beitrag anzeigenGuten Tag,
die Ursache für die Fehlermeldung liegt vermutlich in der Reihenfolge beim Aufrufen von den Funktionen "gtag(...)"
Der Funktionsaufruf bei dem die Default-Einstellungen gesetzt werden, sollte zuerst ausgeführt werden.
Also zuerst:
Code:gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", personalization_storage: "denied", security_storage: "denied", functionality_storage: "denied", wait_for_update: 2000 // milliseconds to wait for update });
Code:gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true});
Das sollte den Fehler beheben.
Beste GrüßeZuletzt geändert von Tim; 22.06.2024, 10:12.
Kommentar
-
Zitat von grobi Beitrag anzeigenGuten Tag,
die Ursache für die Fehlermeldung liegt vermutlich in der Reihenfolge beim Aufrufen von den Funktionen "gtag(...)"
Der Funktionsaufruf bei dem die Default-Einstellungen gesetzt werden, sollte zuerst ausgeführt werden.
Also zuerst:
Code:gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", personalization_storage: "denied", security_storage: "denied", functionality_storage: "denied", wait_for_update: 2000 // milliseconds to wait for update });
Code:gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true});
Das sollte den Fehler beheben.
Beste Grüße
Code:<?php global $objPage; $objRoot = \Contao\PageModel::findByPk( $objPage->rootId ); /** * To use this script, please fill in your Google Analytics ID below */ $GoogleAnalyticsId = $objRoot->analytics_google; /** * DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! */ if ($GoogleAnalyticsId != 'GTM-XXXXXXXXXX' && !BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?> <script id="googletagmanager_<?= $GoogleAnalyticsId; ?>"> // Google Consent Mode window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag("consent", "default", { ad_user_data: "denied", ad_personalization: "denied", ad_storage: "denied", analytics_storage: "denied", personalization_storage: "denied", security_storage: "denied", functionality_storage: "denied", wait_for_update: 2000 // milliseconds to wait for update }); gtag('config', '<?= $GoogleAnalyticsId ?>',{'anonymize_ip': true}); // Enable ads data redaction by default [optional] gtag("set", "ads_data_redaction", true); // Optin privacy setting token var token = localStorage.getItem('user_privacy_settings'); if( token == undefined ) { token = ''; } if(token.indexOf(3) >= 0) { gtag("consent", "update", { ad_user_data: "granted", ad_personalization: "granted", ad_storage: "granted", analytics_storage: "granted", personalization_storage: "granted", security_storage: "granted", functionality_storage: "granted" }); } // listen to privacy event jQuery(document).on('Privacy.changed',function(eve nt,params) { if(params.level.indexOf(3) >= 0) { gtag("consent", "update", { ad_user_data: "granted", ad_personalization: "granted", ad_storage: "granted", analytics_storage: "granted", personalization_storage: "granted", security_storage: "granted", functionality_storage: "granted" }); } }); // Optin privacy setting token if(token.indexOf(3) >= 0) { (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','<?= $GoogleAnalyticsId; ?>'); } // listen to privacy event jQuery(document).on('Privacy.changed',function(eve nt,params) { if(params.level.indexOf(3) >= 0) { //location.reload(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','<?= $GoogleAnalyticsId; ?>'); } }); </script> <?php endif; ?>
Kommentar
-
-
Hier nochmals das korrigierte::
PHP-Code:<?php
global $objPage;
$objRoot = \Contao\PageModel::findByPk($objPage->rootId);
/**
* To use this script, please fill in your Google Analytics ID below
*/
$GoogleAnalyticsId = $objRoot->analytics_google;
/**
* DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
*/
if ($GoogleAnalyticsId != 'GTM-XXXXXXXXXX' && !BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?>
<script id="googletagmanager_<?= $GoogleAnalyticsId; ?>">
// Google Consent Mode
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag("consent", "default", {
ad_user_data: "denied",
ad_personalization: "denied",
ad_storage: "denied",
analytics_storage: "denied",
personalization_storage: "denied",
security_storage: "denied",
functionality_storage: "denied",
wait_for_update: 2000 // milliseconds to wait for update
});
// Enable ads data redaction by default [optional]
gtag("set", "ads_data_redaction", true);
gtag("js", new Date());
gtag('config', '<?= $GoogleAnalyticsId ?>', {'anonymize_ip': true});
// Optin privacy setting token
var token = localStorage.getItem('user_privacy_settings');
if (token == undefined) {
token = '';
}
if (token.indexOf(3) >= 0) {
gtag("consent", "update", {
ad_user_data: "granted",
ad_personalization: "granted",
ad_storage: "granted",
analytics_storage: "granted",
personalization_storage: "granted",
security_storage: "granted",
functionality_storage: "granted"
});
}
// Listen to privacy event
jQuery(document).on('Privacy.changed', function(event, params) {
if (params.level.indexOf(3) >= 0) {
gtag("consent", "update", {
ad_user_data: "granted",
ad_personalization: "granted",
ad_storage: "granted",
analytics_storage: "granted",
personalization_storage: "granted",
security_storage: "granted",
functionality_storage: "granted"
});
}
});
// Optin privacy setting token
if (token.indexOf(3) >= 0) {
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '<?= $GoogleAnalyticsId; ?>');
}
// Listen to privacy event
jQuery(document).on('Privacy.changed', function(event, params) {
if (params.level.indexOf(3) >= 0) {
//location.reload();
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '<?= $GoogleAnalyticsId; ?>');
}
});
</script>
<?php endif; ?>*********************
Neu: Kostenloser Contao Installer 3.0
*********************
Contao und Erweiterungen in wenigen Sekunden laden, installieren und updaten - ohne Composer oder Contao Manager.
Kommentar
Kommentar