Add a cookie banner to every Squarespace page with Code Injection
Add the TermsFeed Privacy Consent cookie banner to a Squarespace site through the Header field of Code Injection, which prints the snippet in the head of every page. Squarespace offers Code Injection on the Core, Plus, and Advanced plans and some legacy plans, according to the Squarespace code injection guide. A site on any other plan has no site-wide field for the snippet.
Setup takes 5 steps and about 15 minutes. You need administrator access to the site and your snippet, which sits under "Install link" on the Overview page of the consent banner in the TermsFeed app. Create the consent banner with Create a Consent Banner where none exists.
Step 1: Paste the Privacy Consent snippet into the "Header" field of Code Injection
Paste the snippet into the Header field, never into a Code Block or the injection of a single page. A Code Block loads Privacy Consent on its own page only, and every other page runs with no consent banner.
- Open Pages > Custom Code > Code Injection (Website Tools > Code Injection on version 7.0).
- Paste the snippet into the Header field.
- Click Save.
The snippet looks like this in the field, with your own token in place of YOUR_TOKEN.
<!-- Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
<script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
<!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
Step 2: Turn off the Squarespace consent banner
Turn off the Squarespace consent banner, so visitors answer one consent banner instead of 2. Open the cookies panel of your site settings, named "Cookies & visitor data", and switch off the toggle beside "Cookie Banner", as the Squarespace cookies article shows.
Decide what happens to Squarespace Analytics
Privacy Consent does not block Squarespace Analytics, because Squarespace sets those cookies itself and there is no snippet to move into a vendor. Squarespace lists ss_cvr, ss_cid, and ss_cpvisit, which last 2 years (24 months), and ss_cvisit and ss_cvt, which last 30 minutes.
To keep the analytics, name Squarespace Analytics and its cookies in your Cookies Policy, so visitors know it runs. To stop the cookies, select Restrict next to "Non-essential Cookies" under Advanced Privacy settings in the same panel, then click Save. Squarespace warns that some of its analytics data is then incomplete, such as clicks, order conversion rates, and referrers. Read what else a browser consent tool does not reach in Blocking Limits.
Step 3: Move Google Analytics and other tracking into Privacy Consent vendors
Delete the measurement ID from the built-in Google Analytics field, because Squarespace prints that tag outside Privacy Consent and it runs before the visitor answers. Then add Google Analytics 4 from its template, which sends the Consent Mode signals for you.
- Open the Developer tools panel and click External API keys.
- Delete the ID that starts with
G-. - Click Save.
- Add Google Analytics 4 as a vendor in the Vendors Manager.
Move every tracking snippet in Code Injection the same way, and leave only the Privacy Consent snippet in the Header field. Set up the vendor with Add Google Analytics 4, and find the other tools in Vendor Recipes.
Step 4: Add a Privacy Preferences link to the Squarespace footer
Add a Code Block to the site footer, so a link that reopens the Privacy Preferences Center shows on every page. Edit the footer of your site, add a Code block, paste this link, and save the footer.
<a href="#" id="open_privacy_preferences_element">Privacy Preferences</a>
Privacy Consent stops the # link from jumping to the top of the page. The floating button of the consent banner opens the Privacy Preferences Center with no change to the footer. Compare the methods with Reopen Preferences.
Step 5: Add the Squarespace domains to the consent banner
List each Squarespace hostname that carries the snippet under "Additional domains" on the Settings page in the TermsFeed app, such as the built-in your-site.squarespace.com address beside your own domain. The built-in address keeps working after you connect a domain, and it loads the same Header field. The consent banner loads only on the main website domain and the additional domains, so the built-in address shows none until you list it. Follow the steps in Multiple Domains.
How to verify Privacy Consent on Squarespace
Save the Code Injection panel first, then test the live site in a new private window, because your normal window stays logged in to Squarespace. Run step 4 on a vendor with an on-accept vendor tag, because only the _ga cookie of the Google Analytics 4 template waits for I Agree.
- Close every private window, open your site in a new one, open the Chrome DevTools Network tab, filter for
termsfeedtag, and reload.plugin.jsand 2settings.jsonrequests return status 200, and the consent banner shows. - Select the second
settings.jsonrequest and open its Preview tab. Theserviceablefield readstrue. - Select the Console tab. No line holds
[ee]or[ww]. - Type the host of a vendor you moved in the Network filter, such as
hotjar.com, and reload. No request appears before you answer. - Select the Application tab and open Cookies for your domain. No
_gacookie exists, and noss_cvrcookie exists once you restrict non-essential cookies. - Click I Agree. Requests to the vendor host appear with no page reload, and the
_gacookie appears. - Type
events.pushin the Network filter. The last request, sent at your click, has status 201. - Click your "Privacy Preferences" link. The Privacy Preferences Center opens.
Repeat the load on a product page, then test the refusal. Close every private window, open a new one with the Network tab filtered on the vendor host, load the Squarespace site, and click I Decline. Open a second page, and no request to that host appears. Run the remaining checks with Verify Your Installation.
How the consent banner behaves on Squarespace Commerce pages
Product, shop, and cart pages load the Code Injection Header like every other page, so they show the same consent banner and read the same answer.
Checkout is the exception. Squarespace states that "Checkout pages don't support code", so Privacy Consent does not run there and does not show a consent banner. Plan conversion tracking around that limit with Unsupported Environments.
Turn off Ajax loading on a Squarespace 7.0 template
Turn off Ajax loading on a Squarespace 7.0 template that offers it, so each page loads as a full page. Ajax loading swaps the page content with no document reload. Privacy Consent looks for replaceable tags once, when it starts, so an embed on a page reached through Ajax loading never gets its placeholder.
Common mistakes with Privacy Consent on Squarespace
- The snippet sits in a Code Block. The page source of other pages lacks
plugin.js. Move the snippet to the Header field of Code Injection. - The snippet sits in the Footer field. The script belongs in the head, ahead of the page content. Move it to the Header field.
- The Squarespace consent banner still shows. Visitors answer 2 consent banners. Switch off the toggle beside "Cookie Banner".
- The Google Analytics ID stays in External API keys. Squarespace prints the Google tag before consent, next to the vendor. Delete the ID that starts with
G-. - Squarespace Analytics is missing from the Cookies Policy. Privacy Consent does not block it, so name it in the policy or restrict non-essential cookies.