Drupal is a powerful open-source digital experience management system used by over 1 million contributors worldwide to deliver personalized web content at scale. This guide explains how to install the Secure Privacy cookie consent script on a Drupal 8 or 9 website using the Header and Footer Scripts module.
Before you begin: You will need your unique Secure Privacy installation script. Log in to your Secure Privacy account at secureprivacy.ai and copy the script from the Domains → Installation page.
Who Is This Guide For?
Website administrators managing Drupal 8.x or 9.x websites
Developers integrating Secure Privacy with a Drupal-powered website
In this guide:
Step 1: Install the Header and Footer Scripts Module in Drupal
The Secure Privacy integration for Drupal 8/9 uses the Header and Footer Scripts module. Download it here: Header and Footer Scripts Drupal Module.
If you are already experienced with installing Drupal modules, skip directly to Step 2.
Download the Module
Navigate to the "Downloads" section on the module page.
Copy the URL for the latest Drupal release. It will look similar to:
https://ftp.drupal.org/files/projects/header_and_footer_scripts-3.0.0.tar.gz

Install and Enable the Module in Drupal 8/9
In your Drupal admin dashboard, navigate to Manage → Extend and click "Add new module."
Paste the copied module URL into the "Install from a URL" field and click "Continue."

Once uploaded, locate "Header and Footer Scripts" in the Extend module list.

Check the checkbox next to "Header and Footer Scripts" and click "Install" to enable the module.

Step 2: Add the Secure Privacy Script Using the Header and Footer Scripts Module
In your Drupal admin dashboard, navigate to Configuration → Header and Footer Scripts.
Paste your Secure Privacy installation script into the "Header Scripts" field to ensure it loads before any non-essential cookies are set.

Click "Save configuration" to apply the changes.

The Secure Privacy cookie consent script is now installed on your Drupal website. Your site is ready to manage user consent and GDPR compliance via Secure Privacy.
Common Issues and Fixes
Where do I find my Secure Privacy installation code?
Log in to your Secure Privacy account and navigate to Domains → Installation. Your unique script code is displayed and available to copy from this page.
I don't see "Header and Footer Scripts" in Drupal's Extend menu.
Ensure you uploaded the module correctly using the "Add new module" option and the latest module URL from Drupal.org. After uploading, the module must be enabled by checking its checkbox in the Extend list and clicking "Install."
My Secure Privacy consent banner is not showing after installation.
Clear your Drupal cache and refresh your website. Also confirm the script is correctly pasted in the "Header Scripts" field under Configuration → Header and Footer Scripts — not the Footer Scripts field.