Prestashop module - Optimize your Google Analytics module

“Use your browser cache” for the Google Analytics module in Prestashop


If you are struggling with the optimization problem of Prestashop for Google PageSpeed Insights for the Google Analytics module (JavaScript) loaded from Google servers, I have a solution for you – the Prestashop Module!

The problem is that the ganalytics module loads the content of scripts directly from Google servers that we can not keep in the cache. In this case, we must set the HTTP headers for these files (Expires), which should be on our server and be kept for some time in the client’s browser cache. The best way to add the Expires headers is to add the following code to the .htaccess file in the main directory of your Prestashop:

Adding the above Expires headers will improve the PageSpeed Insights result in the test but it still does not solve the problem. To fully support the Google Analytics file from my own server, install my module which you can download below:


How it works?

Moduł do optymalizacji sklepu Prestashop dla Google Page Speed

The module clipartoptimizegoogleanalytics (Optymize Google Analytics) overwrites the functions of the original ganalytics module (Google Analytics for Prestashop) in such a way that the script does not download the content of JavaScript files from external sources. The module has a tool that should be set in the task schedule (cron) so that JavaScipt files are downloaded and updated on the server.

Installation guide

STEP1: Install the module with the standard tool for adding Prestashop modules: Modules and services -> Add a new module and then “Install”

STEP 2: Go to the module configuration and copy the generated URL to the CRON tool which should be called cyclically once a day. The url should be pasted into the hosting panel in the Task Scheduler (Cron) tool. Below is an example for the Ajenti panel:


Post Comments:

  1. 26 December 2018

    Mam Ganalyticsa, mam Wasz moduł i próbując uruchomić crona:
    The file /home/dumledo2/domains/ does not exist. You do not have installed a Google Analytics module.Done.

    1. 14 January 2019

      Skrypt sprawdza w pierwszej kolejności czy moduł jest aktywny w Prestashop. Czy jesteś pewien że tak jest?

  2. 22 March 2019

    Jak dla mnie ten warunek zawsze będzie pokazywał taki komunikat nawet jak oryginalny moduł Google będzie istniał:
    if (file_exists($filename)) {
    echo $this->module->l(‘The file ‘) . $filename. $this->module->l(‘ does not exist. You do not have installed a Google Analytics module.’);
    } else {
    echo $this->module->l(‘The file ‘) . $filename. $this->module->l(‘ does not exist. You do not have installed a Google Analytics module.’);

Add comment