How to add custom code to a Squarespace site
Squarespace calls its site-wide script box Code Injection. Whatever you paste into the Header field is injected into the head tag on every page. Saving is the whole deployment; there is no publish step.
Before you start
- A Core, Plus or Advanced plan. Squarespace says some legacy billing plans include code injection too.
- The script from your tool, as a complete <script> tag
- A login that can open the site’s Code Injection panel
Steps
- Open the Code Injection panelOn version 7.1, open the Pages panel, click Custom Code at the bottom, then Code Injection. On version 7.0 the panel sits under Website Tools.
- Paste the script into HeaderUse the Header field. The panel has other fields, including a separate one for the order confirmation page. Leave those empty unless your tool asks for them.
<script defer src="https://example.com/tool.js"></script>An example tag. Use the one your tool supplied. - SaveClick Save. The script is on the site from that point.
- Look at the site the way a visitor doesInjected code can run inside the editor preview, which makes the preview a poor test. Open your site’s URL in a private window instead.
Check it worked
- In a private window, view the source of any page and search for the script’s address inside the head.
- Open a second page and confirm the Network tab in developer tools shows the script there as well.
What goes wrong
- There is no Code Injection option
- The site’s plan does not include it. Squarespace lists Core, Plus, Advanced and some legacy billing plans. Check which plan the site is on.
- The script is missing on checkout
- Squarespace states that checkout pages don’t support code. Plan around that; there is no setting that changes it.
- It works in the editor and you call it done
- Code running in the editor preview tells you little about what a visitor gets. Test in a private window on the real URL before telling anyone the install is finished.
Checked on 2026-11-11 against Squarespace Help Center: Using code injection.
Increase conversions on your Squarespace site by 20%
Dynamite personalizes the page for every visitor. Dynamite personalizes a Squarespace site from one script line in the Header field of Code Injection. From there you decide which parts of a page may change and who sees each version.
Dynamite for SquarespaceQuestions
Which Squarespace plans allow code injection?
Squarespace’s help article lists the Core, Plus and Advanced plans, and some legacy billing plans.
Do I have to publish after adding code?
No. Code in the Header field is live once you save.
Can I run a script on Squarespace checkout?
No. Squarespace says checkout pages don’t support code. The order confirmation page has its own field in the same panel.