Moin liebe Matomogemeinde,
ich bekomme meine custom Optout Variante für Matomo nicht zum laufen.
Installiert ist die Matomo instance und aufrufbar über matomo.example.de
Entsprechend ist für example.de das Tracking im Head eingebunden:
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.example.de/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//matomo.example.de/matomo.php?idsite=1&rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
Auf der Datenschutzseite habe ich dann die custom opt out Variante eingebunden:
(siehe JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3)
<div id="optout-form">
<p>You may choose not to have a unique web analytics cookie identification number assigned to your computer to avoid the aggregation and analysis of data collected on this website.</p>
<p>To make that choice, please click below to receive an opt-out cookie.</p>
<p>
<input type="checkbox" id="optout" />
<label for="optout"><strong></strong></label>
</p>
</div>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
function setOptOutText(element) {
_paq.push([function() {
element.checked = !this.isUserOptedOut();
document.querySelector('label[for=optout] strong').innerText = this.isUserOptedOut()
? 'You are currently opted out. Click here to opt in.'
: 'You are currently opted in. Click here to opt out.';
}]);
}
var optOut = document.getElementById("optout");
optOut.addEventListener("click", function() {
if (this.checked) {
_paq.push(['forgetUserOptOut']);
} else {
_paq.push(['optUserOut']);
}
setOptOutText(optOut);
});
setOptOutText(optOut);
});
</script>
Es wird kein Cookie für die Subdomain gesetzt, evtl. fehlt hier irgendein verweis auf die Subdomain?
Danke für eure Hilfe
Liebe Grüße
Hendrik