How to Inject Code Into Your Squarespace Website Header & Footer
If you’ve ever received a code snippet from a third-party provider, whether for analytics, a chatbot, or tracking pixels, they’ll often tell you: “Add this to your site’s header or footer.” But where exactly do you paste that code in Squarespace?
In this quick guide, I’ll show you exactly where and how to add custom code to your Squarespace site using the built-in Code Injection tool, whether it’s sitewide or just for a single page.
What Is Code Injection in Squarespace?
Code Injection is a feature in Squarespace that allows you to insert custom code (such as HTML, CSS, JavaScript, or third-party scripts) directly into your site’s header, footer, or even specific pages.
This is especially useful for:
Adding Google Analytics or Facebook Pixel
Verifying your site with tools like Google Search Console
Integrating third-party marketing tools
Custom styling or scripts that must load sitewide
Want a framework for designing the perfect homepage?
Need an expert to build your Squarespace website?
Book a free kick-off call with our team to discuss your project requirements in detail.
Where to Add Code in Squarespace
Option 1: Sitewide Header or Footer Code Injection
To add code that affects your entire website (like tracking scripts or sitewide styling), follow these steps:
Step 1: Go to Code Injection Settings
From your Squarespace dashboard, click Settings
Scroll down and select Custom Code
Click Code Injection
Step 2: Paste Code Into Header or Footer
You’ll see two main fields:
Header - code placed here will load before the page content (ideal for analytics or CSS)
Footer - code placed here loads after the page content (great for scripts like chatbots or popups)
Just paste your provided code snippet in the appropriate section and save.
Option 2: Inject Code on a Single Page
Sometimes, a code snippet only needs to appear on one specific page. Here’s how to do that:
Step 1: Navigate to the Page
Go to Pages in your dashboard
Hover over the page where you want to add code
Click the settings cog icon
Step 2: Add Code to the Page
Go to the Advanced tab
In the Page Header Code Injection field, paste your code
This only applies to that single page, perfect for tools or embeds that shouldn’t load sitewide.
Wrapping Up
Whether you’re adding Google Analytics, a verification meta tag, or a third-party script, Squarespace makes it easy to inject custom code both sitewide or per page.