Add a cookie banner to your Squarespace site with "Code Injection"
Paste the TermsFeed Free Cookie Consent code into Footer Code Injection, turn off the Squarespace cookie banner, and clear the built-in analytics field. Cookie Consent then shows its consent banner on every page and, by default, holds the optional tagged scripts until the visitor accepts their categories.
Setup takes 4 steps and about 20 minutes. Code Injection is part of the Core, Plus, and Advanced plans and some legacy plans, so a site on the Basic plan has no place for the code. Before you start, generate the code at termsfeed.com/cookie-consent and keep the generator defaults, which use express consent.
Step 1: Paste the Cookie Consent code into footer "Code Injection"
Paste the code into the Footer field of Code Injection, which Squarespace places right before the closing </body> tag on every page. A Code Block or the page-level injection of a single page shows the consent banner on that page only. Squarespace does not run any code on checkout pages, so the consent banner never shows there.
Paste the code from the Code Injection panel, then look at the live site.
- Open Pages > Custom Code > Code Injection in the Squarespace editor (Website Tools > Code Injection on version 7.0), the panel the Squarespace code injection guide describes.
- Paste the code into the Footer field, and leave out the "Update cookies preferences" link the generator adds at the end.
- Click Save.
- Close every private window, open your live site in a new one, and check that the consent banner appears.
Your generator code has the shape of this example. Keep your own options. The example writes the script address with https:, which the generator leaves out, and both forms load the same file.
<!-- Cookie Consent by TermsFeed https://www.TermsFeed.com -->
<script type="text/javascript" src="https://www.termsfeed.com/public/cookie-consent/4.2.0/cookie-consent.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
document.addEventListener('DOMContentLoaded', function () {
cookieconsent.run({"notice_banner_type":"headline","consent_type":"express","palette":"dark","language":"en","page_load_consent_levels":["strictly-necessary"],"notice_banner_reject_button_hide":false,"preferences_center_close_button_hide":false,"page_refresh_confirmation_buttons":false,"website_name":"Example Store"});
});
</script>
<noscript>Free cookie consent management tool by <a href="https://www.termsfeed.com/">TermsFeed Generator</a></noscript>
<!-- End Cookie Consent by TermsFeed https://www.TermsFeed.com -->
You add the preferences link to the footer of the site instead. Find what each part of the code does in Install a Cookie Banner on Any Website.
Step 2: Turn off the Squarespace consent banner
Turn off the Squarespace consent banner and restrict non-essential cookies, so visitors answer one consent banner and Squarespace sets none of its own optional cookies. The Squarespace consent banner governs Squarespace analytics and some integrations Squarespace connects, such as the built-in Google Analytics field. Cookie Consent does not hold Squarespace analytics.
Change 2 settings in the cookies panel of your site settings, named "Cookies & visitor data", as the Squarespace cookies article shows.
- Switch off the toggle beside "Cookie Banner".
- Under Advanced Privacy settings, select Restrict next to "Non-essential Cookies".
- Click Save.
The restriction stops Squarespace from setting its analytics cookies, such as ss_cvr and ss_cvt, for every visitor. Squarespace warns that some Squarespace analytics data, such as clicks, order conversion rates, and referrers, is then incomplete. Squarespace adds that the restriction does not disable every cookie that a connected third-party service sets.
Step 3: Remove the measurement ID from the built-in analytics field
Delete the measurement ID from the built-in Google Analytics field, because Squarespace prints that tag outside your code and Cookie Consent never holds it. Open the Developer tools panel, click External API keys, delete the ID that starts with G-, and click Save.
Paste each script into the Footer field of Code Injection instead, below the Cookie Consent code, tagged with its category, and click Save. Take the tagged Google Analytics 4 tag from Block Google Analytics 4 Until Consent, and the code of every other tool from Vendor Recipes for Free Cookie Consent.
Step 4: Add a footer link that reopens the Preferences Center
Add a Code Block to the site footer with a link that carries the id open_preferences_center, so visitors reopen the Preferences Center from every page. Cookie Consent opens the Preferences Center on a click on any element with that id, wherever the element sits in the page. The footer of a Squarespace site shows on every page, so one block covers the whole site.
Edit the footer of your site, add a Code block, and paste this link. Then save the footer.
<a href="#" id="open_preferences_center">Cookie settings</a>
Once Cookie Consent runs, it stops the # link from jumping to the top of the page. Style the link with the text styles your site uses, or compare the other ways to open the Preferences Center in Add a Cookie Settings Link.
How to verify Cookie Consent on your Squarespace site
The checks assume express consent with page_load_consent_levels left out or at the generator value ["strictly-necessary"], and the "I decline" button shown. Close every private window, then check the live site in a new one with Chrome DevTools open, because your normal window is logged in to Squarespace. The new window starts without Cookie Consent cookies, so you see the consent banner a first-time visitor sees.
Keep that private window open for every check, and run them in order. Publish your change and clear any page cache first.
- Open your site in the new private window, open DevTools, select the Network tab, type
cookie-consentin the filter box, and reload. The loadercookie-consent.js, the scriptcookie-consent-code.js, and the ping appear, and the consent banner shows. - Type the host of one tagged script in the filter box and reload. No request appears before you answer.
- Click the "I agree" button. Requests to that host appear without a page reload.
- Select the Application tab, open Cookies for your domain, and check that
cookie_consent_levelandcookie_consent_user_acceptedexist. - Check that no
ss_cvrcookie exists in the same list. - Click the "Cookie settings" link in the footer. The Preferences Center opens.
To check a refusal, close every private window, repeat steps 1 and 2 in a new one, and click the "I decline" button. Open a second page and confirm that the Network tab does not list any request to the host of the tagged script. Run the platform-independent checks in Check That Your Cookie Banner Works.
Common mistakes with Cookie Consent on Squarespace
Start with the field that holds the code, then clear what Squarespace still adds on its own: its Google Analytics field, its consent banner, and its cookie setting.
- The code sits in a Code Block or in the injection of one page. The page source of the other pages does not hold
cookie-consent.js. Move the code to the Footer field of Code Injection. - The built-in Google Analytics field still holds the measurement ID. Analytics requests appear in the Network tab before you answer, and after you accept, every page view counts twice if you added a tagged copy in the Footer field too. Delete the ID under External API keys.
- The Squarespace consent banner still shows. Visitors answer 2 consent banners. Switch off the toggle beside "Cookie Banner" in "Cookies & visitor data".
- Non-essential cookies are not restricted. The
ss_cvrcookie appears before the visitor answers. Select Restrict next to "Non-essential Cookies" in "Cookies & visitor data". - The preferences link appears twice. The generator link in Code Injection and the Code Block in the footer both show. Delete the link from Code Injection.
Cookies that a tracker set before a visitor withdraws consent stay in the browser, because Cookie Consent does not delete cookies that other scripts set. Find every limit and its workaround in Limits of Free Cookie Consent: What It Does Not Do.