How to Add Cookie Banner on an HTML Website

If your website uses cookies or third-party tracking technologies, it’s essential to comply with privacy regulations like the GDPR. Adding a cookie consent banner ensures that user data isn’t collected without explicit permission.

In this guide, you’ll learn how to integrate a cookie banner on a static HTML website using Consentise.

  1. Visit the Consentise Generate Consent Banner page.
  2. Fill in the required fields:
    • Your website domain (e.g., www.example.com)
    • Privacy Policy URL (e.g., https://www.example.com/privacy-policy)
    • Default Language (e.g., en, de, fr, etc.)
  3. Click the Generate Script button.

Consentise will provide you with two scripts:

  • Mandatory Script: Must be placed in the <head> section of your website.
  • Consent Banner Script: Should be placed in the <body> section.

Step 2: Add the Mandatory Script in the <head>

Copy and paste the following script before any other scripts (e.g., Google Tag Manager or Analytics) in your <head> tag:

<script>
// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('set', 'url_passthrough', true);
gtag('set', 'ads_data_redaction', true);
gtag('consent', 'default', {
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied',
  'analytics_storage': 'denied'
});
// UET default settings
window.uetq = window.uetq || [];
window.uetq.push('consent', 'default', {
  'ad_storage': 'denied'
});
</script>

Important: This script must come before any cookie-setting or tracking code to ensure compliance.

Place the following script anywhere in your page’s <body>, preferably at the bottom:

<script src="https://www.consentise.com/v1.2/consent-min.js" 
data-cookiedomain="www.your-website.com" 
data-privacy-policy-url="https://www.your-website.com/privacy-policy" 
data-preferred-color="#4fa5d3"
data-banner-position="bottom"
data-default-language="en"
defer></script>

Make sure to:

Replace www.your-website.com with your actual domain.
Update the Privacy Policy URL if needed.
Customize banner color (data-preferred-color), position, and language.

Step 4: Test the Banner

After implementing both scripts:

  1. Open your website in an incognito window.
  2. Ensure the banner is displayed.
  3. Confirm that no cookies or trackers are loaded until the user gives consent.

You can use tools like Tag Assistant or browser dev tools to verify cookie behavior.

By following these steps, your website will be equipped with a GDPR-compliant consent solution, helping you protect user privacy and meet legal requirements. If you need more advanced features like geolocation, multi-language support, or consent logs, explore additional options at the Consentise pricing page.