CookieConsentHQ

Integrations

Add CookieConsentHQ to any HTML website

Paste the CookieConsentHQ script as the first tag after the opening head on every page, or once in the shared template every page uses, then publish. It must load without async or defer, before analytics and ad tags.

Get your install codeFree plan, no card needed.
Installation type
One script tag
Code location
First tag inside head
Script loading
Synchronous; no async or defer
Tag managers
Snippet above the container code
Single-page apps
Once, in the HTML shell
Verification
Verify installation in the dashboard; free checker at /check

Where do I put the CookieConsentHQ script in HTML?

Place the script immediately after the opening <head> tag, before any other scripts. Copy the snippet from the Install tab in your CookieConsentHQ dashboard.

Your HTML looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://cdn.cookieconsenthq.com/s/YOUR_SITE_KEY.js"></script>
  <!-- analytics, tag manager and other scripts come after -->
</head>

The script must load synchronously, so don't add async or defer. Position matters because CookieConsentHQ can't stop a tracker that has already run, so analytics and advertising scripts must come after it.

If you use a tag manager, place the CookieConsentHQ snippet above the tag manager's container code.

How do I add it to every page?

Add the script once to the shared header template or layout that every page uses, or to each HTML file. Then publish or deploy the updated files.

  • Hand-coded sites with separate files: paste the snippet right after the opening <head> in each file.
  • Static site generators and custom CMSs: put it in the shared template that produces the page's <head>.
  • Single-page apps: add it once to the HTML shell's <head>; it stays loaded as the app changes routes.

Check pages that don't use the shared template. Old landing pages and error pages may need the snippet added separately.

See the installation documentation for the shared setup steps.

Use the manual blocking attributes when a script or iframe must not load before consent. A marketing script becomes:

<script type="text/plain" data-cchq="marketing" src="..."></script>

Use analytics or functional where that fits. A normal <script src> tag is stopped from running, but the browser may still fetch it early; type="text/plain" stops that request too.

For a marketing iframe, move the address into data-cchq-src:

<iframe data-cchq="marketing" data-cchq-src="..."></iframe>

How do I check the published HTML?

Look at the published HTML, not only your source files: a plugin, build step or CDN can rewrite or reorder the head on the way out. Confirm that CookieConsentHQ is the first script in <head>, without async or defer, and that no analytics, advertising or tag manager script comes before it.

The Verify installation button in your dashboard does this for your homepage. It loads the page as a new visitor and checks the script for your site, its position, the banner, cookies set before consent, Google Consent Mode defaults and the live banner version.

The free checker checks any single page for cookies set before consent, hardcoded tracker tags and Consent Mode v2 defaults.

Add <div data-cchq-cookie-table></div> where your cookie list should appear; the cookie scanner fills it. To let visitors reopen their choices, call CCHQ.showPreferences(), for example from a "Cookie settings" link in your footer.

Each choice is kept in your consent log.

This page is technical installation guidance, not legal advice.

Questions

Where exactly does the script go?
Right after the opening head tag, before any other script, on every page or in the shared header template.
Can I load it with async or defer?
No. The script must run before analytics and advertising tags, because it can't stop a script that has already run.
I use Google Tag Manager. Where does the snippet go?
Above the tag manager's container code in the head.
Does it work in a single-page app?
Yes. Add it once to the HTML shell's head; it stays loaded as the app changes routes.