How to add custom code injection on Squarespace
Custom code injection in Squarespace allows you to add HTML, CSS, or JavaScript to your site through Settings > Advanced > Code Injection. You can inject code site-wide in headers/footers or on specific pages for tracking, styling, or functionality enhancements.
Prerequisites
- Active Squarespace website
- Basic HTML/CSS knowledge
- Business plan or higher (for some advanced features)
- Admin access to your Squarespace site
Step-by-Step Instructions
Access your Squarespace admin panel
Navigate to Code Injection settings
Choose injection location
<head> tag, Footer loads before the closing </body> tag, and Order Confirmation is for e-commerce tracking.Add your custom code
<style> tags. For JavaScript, use <script> tags. For example:<style>
.custom-class {
color: #ff6b6b;
}
</style>Save your changes
Add page-specific code (optional)
Test and verify your code
Common Issues & Troubleshooting
Code injection option is not available
Code injection requires a paid Squarespace plan. Upgrade from the Personal plan to Business or higher to access this feature. Some advanced code injection features may require Commerce plans.
Custom CSS or JavaScript not working
Ensure your code is properly wrapped in <style> or <script> tags. Check for syntax errors and verify the code works in a separate HTML file first. Use browser developer tools to check for console errors.
Code appears as text on the website
This usually means the code wasn't properly wrapped in HTML tags. Make sure CSS is within <style></style> tags and JavaScript is within <script></script> tags.
Changes not visible after saving
Clear your browser cache and try viewing in an incognito/private browsing window. Squarespace may take a few minutes to propagate changes. Also check that you saved the changes and didn't just close the code injection panel.