Add a cookie consent banner to a Squarespace site

Cookbook · platform View raw markdown (for agents)

In short: paste the live snippet in Code Injection → Header, on a plan that includes code injection. The Header field is written into the <head> of every page. Put your analytics tags in the same field, below the snippet.

You need #

Where it goes #

Steps follow Squarespace: code injection.

  1. Copy the live snippet (see above).

  2. Open the Code Injection panel in your site settings.

  3. Paste the snippet in the Header field, with your analytics tags below it if you have any:

    <script>
        var huOptions = { "appID": "YOUR_APP_ID", "currentLanguage": "en", "blocking": true, "globalCookie": false };
    </script>
    <script src="https://cdn.hu-manity.co/v2/hu-banner.min.js" type="text/javascript" charset="utf-8"></script>
    
  4. Click Save.

Squarespace writes the Header field into the <head> of every page, so one entry covers the whole site.

What the order controls #

The banner holds recognised trackers that load after it until the visitor chooses, in regions whose rule requires consent first. A script placed above the snippet runs straight away, and a script you mark data-hu-category="1" is treated as essential. What runs before consent is your decision, so keep analytics and pixels below the snippet.

Confirm the result #

View the page source of the published site, not the editor or its preview (use the browser's View Source, not the Elements panel): the huOptions script and hu-banner.min.js are in <head> as plain synchronous tags (no async or defer), and your analytics tags come after them. Squarespace's own scripts may also appear in <head>; what matters is that your analytics and pixels come after the banner snippet.

Then run the browser checks in plain-html in a private window (banner shows, no tracking cookies before the visitor chooses in a region whose rule requires consent first, trackers start after Allow) and, for the full procedure, verify-install. Test from a region your strictest rule covers (for example the EU), or confirm region rules are off.

Gotchas #

More help #