Search code examples
javascriptgoogle-analyticsprestashopadminprestashop-1.7

Google analytics in Prestashop 1.7 admin


I'm trying to insert Google Analytics into our backoffice, does anyone have found the good file to edit or a module for this ?

So far I tried with /admin/themes/templates/header.tpl but it failed sadly.

Did anyone achieved to do this ?


Solution

  • You have to edit two files :

    • For the login page : /admin/themes/default/template/controllers/login/header.tpl

    • For all others : /admin/themes/new-theme/template/header.tpl

    Then just add literal in smarty template to escape the JS from being executed :

    {literal}
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
    
      gtag('config', 'UA-XXXXX-X'); // Replace your UA here
    </script>
    {/literal}