Fehler: Google Analytics snippet einbinden

Karl-Ludwig Grosch's Avatar

Karl-Ludwig Grosch

16 Jun, 2021 08:23 AM

Produkt: Tao Contao
Contao-Version: 4.9
Browser und Browserversionen: alle

Inden Template gibt es kein gtag.js in das die G-ID eingetragen werden könnte. Wie ist hier vorzugehen? Das bisherige analytics_google.html5 ist nicht verwendbar.

  1. Support Staff 1 Posted by RockSolid Theme... on 16 Jun, 2021 02:09 PM

    RockSolid Themes's Avatar

    Vielen Dank für Ihre Frage.

    Das analytics_google.html5 Template können Sie folgendermaßen anpassen:

    <?php
    
    // To use this script, please fill in your Google Analytics ID below
    $GoogleAnalyticsId = 'UA-XXXXX-X';
    
    // DO NOT EDIT ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!
    if (!BE_USER_LOGGED_IN && !$this->hasAuthenticatedBackendUser()): ?>
    
    <script async src="https://www.googletagmanager.com/gtag/js?id=<?= $GoogleAnalyticsId ?>"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', '<?= $GoogleAnalyticsId ?>', { 'anonymize_ip': true });
    </script>
    
    <?php endif; ?>
    

    Ersetzen Sie dabei bitte UA-XXXXX-X mit Ihrer Google-Analytics-ID.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac