In folgendem Template werden der Variablen verwendet: GA_TRACKING_ID, CC_POPUP_BGCOL und CC_POPUP_TXTCOL
[code]<script src="fileadmin/templates/js/cookieconsent.min.js" data-cfasync="false"></script>
<script>
function loadGAonConsent(){
var gs = document.createElement("script");
gs.async = true;
gs.src = "https://www.googletagmanager.com/gtag/js?id={GA_TRACKING_ID}";
var h = document.getElementsByTagName("head")[0];
h.appendChild(gs, h);
gs.onload = function (){
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', '{GA_TRACKING_ID}', { 'anonymize_ip': true });
nonsense('{CC_POPUP_BGCOL}', '{CC_POPUP_TXTCOL}');
}
}
if(document.cookie.split(';').filter(function(item){return item.indexOf('cookieconsent_status=allow') >= 0}).length)
loadGAonConsent();
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "'{CC_POPUP_BGCOL}'",
"text": "'{CC_POPUP_TXTCOL}'"
},
"button": {
"background": "#4b81e8"
}
},
"theme": "classic",
"type": "opt-in",
"content": {
"policy": "Datenschutzeinstellungen",
"message": "Cookies",
"deny": "Ablehnen",
"allow": "Akzeptieren",
"link": "Mehr Informationen",
"href": "/link/zur/dse"
},
onStatusChange:function(status,chosenBefore){
if(this.hasConsented())
loadGAonConsent();
}
});
</script>
[/code]
GA_TRACKING_ID werden beide Vorkommen ersetzt, aber in der JavaScript Funktion "window.cookieconsent.initialise()" die beiden CC_POPUP_BGCOL und CC_POPUP_TXTCOL nicht.
Ich hab dann einfach testweise bei Aufruf des JS-Funktionen "gtag()" mal eine nicht existierende funktion "nonsense()" aufgerufen, mit CC_POPUP_BGCOL und CC_POPUP_TXTCOL als Parameter und seltsameweise werden diese beiden ersetzt. Kann mir das jemand erklären?
Danke
Lars