Cookie compliance integration for PrestaShop 8.0 and 1.7

Nelson
Written by NelsonLast updated 1 day ago

You can install the CookieScript module on PrestaShop 8.0, PrestaShop 1.7, and other versions.

There are three ways to install CookieScript on PrestaShop:

  • By using the CookieScript module (for PrestaShop 8.0).

  • By adding the CookieScript banner code manually (for PrestaShop 1.7 and other versions that support code installation).

  • CookieScript installation with Google Tag Manager (GTM) (for all versions, including PrestaShop 8.0 and PrestaShop 1.7).

To install and configure the CookieScript module on PrestaShop 8.0, perform the following steps:

  1. Register at CookieScript.

  2. In your CookieScript account, open your banner and go to Install:

    image.png
  3. Configure geo-targeting (if needed).

  4. Select Script tag and copy the file URL from the src attribute of the code (the part that starts with //cdn.cookie-script.com/s/ and ends with .js).

  5. Then, go to PrestaShop and download the CookieScript module.

  6. In your PrestaShop admin, go to the Settings tab at the bottom of the left menu and paste the file URL into the Script URL field:

    1_setup_new.png
  7. Enable Google Consent Mode v2 by selecting the checkbox:

    2_google%20consent_new.png


    Once enabled, you can control the settings of Google Consent Mode separately.

  8. Lastly, configure regional settings by clicking Add new region, then click Save to save your changes:

    3_new%20region_new.png


  9. The CookieScript module is now turned on. To turn it off temporarily, click Unpublish.

That’s all! You have installed and configured the CookieScript cookie banner module on PrestaShop 8.0.

Also read the following guides:

How to install CookieScript with Google Tag Manager (GTM)?

How to install Google Consent Mode v2 with GTM?

How to select Basic or Advanced Google Consent Mode implementation at your GTM account?

To install CookieScript on PrestaShop 1.7 manually, follow these steps:

  1. Register at CookieScript.

  2. In your CookieScript account, open your banner and go to Install:

    image.png
  3. Configure geo-targeting (if needed).

  4. Select Script tag and copy the file URL from the src attribute of the code (the part that starts with //cdn.cookie-script.com/s/ and ends with .js).

  5. Then, go to PrestaShop and add the CookieScript code manually:

    Open the {project_directory}/classes/controller/FrontController.php file.

    Find the setMedia() function.

    Add the following code, where your-file-URL is the file URL you copied from the src attribute:

    $this->registerJavascript(
    'remote-bootstrap',
    'your-file-URL',
    ['server' => 'remote', 'position' => 'head', 'priority' => 20]
    );
    

    The 'position' => 'head' setting loads CookieScript in the <head> section of every page. We recommend this, so that CookieScript loads before other scripts and can block their cookies.

    You can also use 'position' => 'bottom' to load the file at the end of the <body> tag, but then scripts that load earlier may set cookies before CookieScript can block them.

CookieScript is now installed on PrestaShop 1.7 and ready to use.

Note: If the banner doesn't appear after installation, check whether a caching module or browser extension is preventing it from showing.

Also read the following guides:

How to install CookieScript with Google Tag Manager (GTM)?

How to install Google Consent Mode v2 with GTM?

How to select Basic or Advanced Google Consent Mode implementation at your GTM account?

Did this article help you solve your issue?