Docs menu

Installation

Installing CookieHug: the JavaScript snippet in <head>, script attributes, full configuration and script blocking modes.

Installation

Basic Snippet

Place the script tag in the <head> of your HTML, before any third-party scripts (analytics, ads, etc.). Copy the exact tag from your dashboard (Domain → Code) — the license key is part of the script URL:

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://cookiehug.com/api/script/YOUR-LICENSE-KEY.js"></script>
  <!-- Other scripts go AFTER CookieHug -->
</head>

Script Tag Attributes

AttributeTypeRequiredDefaultDescription
data-ecidstringLegacy only—Only for the older loader form (cookieconsent.js); with the snippet above the license key is part of the script URL
data-cookiehug-langstringNoauto-detectForce banner language (ISO 639-1, e.g. "EN", "DE", "PL")
data-cookiehug-blockingmodestringNo"auto""auto" = automatic script blocking, "manual" = manual only
data-cookiehug-consentmodestringNo"enabled""enabled" = Google Consent Mode v2 active, "disabled" = GCM disabled

Full Configuration Example

<script
  data-cookiehug-lang="EN"
  data-cookiehug-blockingmode="auto"
  data-cookiehug-consentmode="enabled"
  src="https://cookiehug.com/api/script/YOUR-LICENSE-KEY.js">
</script>

Automatic vs Manual Blocking Mode

Automatic mode (data-cookiehug-blockingmode="auto", default): CookieHug automatically detects and blocks third-party scripts, iframes, and tracking pixels. Uses pattern matching against known tracking domains. No additional markup needed.

Manual mode (data-cookiehug-blockingmode="manual"): Automatic blocking is disabled. You control which scripts require consent using the data-cookiehug-consent attribute. Useful when you need precise control over script loading.