Contao-Summit 2026

Ankündigung

Collapse
No announcement yet.

Contao 5.3 - Matomo - Consent-Bannerfrei Einstellungen?

Collapse
X
 
  • Filter
  • Zeit
  • Show
Clear All
new posts

    #16
    Du solltests ggf. noch die Anpassungen von Joachim Nickel übernehmen. Dann erwischst du auch die Besucher, die mit AdbockPlus, uBlock oder Brave unterwegs sind.

    Dann sieht das Template so aus:
    Code:
    if ($MatomoSite > 0 && '//www.example.com/matomo/' != $MatomoPath && !$this->hasAuthenticatedBackendUser()): ?>
    
    <script<?= $this->attr()->setIfExists('nonce', $this->nonce('script-src')) ?>>
      var _paq = window._paq = window._paq || [];
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u='<?= $MatomoPath ?>';
        _paq.push(['setTrackerUrl', u+'js/']);
        _paq.push(['setSiteId', <?= $MatomoSite ?>]);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.async=true; g.defer=true; g.src=u+'js/'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    
    <?php
    
    $this->addCspSource('script-src', $MatomoPath);
    endif;
    Oder, wenn du den Contao Tag Manager nutzen willst:
    Code:
    <?php
    
    // To use this script, please fill in your Matomo site ID and Matomo URL below
    $MatomoPath = '//www.example.com/';
    $MatomoContainerId = '';
    
    // DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
    if ($MatomoContainerId != '' && '//www.example.com/matomo/' != $MatomoPath && !$this->hasAuthenticatedBackendUser()): ?>
    
    <script<?= $this->attr()->setIfExists('nonce', $this->nonce('script-src')) ?>>
      var u='<?= $MatomoPath ?>';
      var c='<?= $MatomoContainerId ?>';
      var _mtm = window._mtm = window._mtm || [];
      _mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
      (function() {
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.async=true; g.src=u+'js/container_'+c+'.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    
    <?php
    
    $this->addCspSource('script-src', $MatomoPath);
    endif;
    Last edited by neelix; 13.08.2025, 21:47.

    Comment


      #17
      Zitat von neelix Beitrag anzeigen
      Du solltests ggf. noch die Anpassungen von Jochen Nickel übernehmen
      Jochen Nickel ist ein Schauspieler, du meinst wohl Joachim Nickel
      Contao-Association unterstützen

      Comment

      Working...
      X