Custom HTML and Script Insertion Guide - How to Add Code to Your Squarespace Site
Code Insertion is a feature that allows you to enhance your site with custom HTML and scripts in specific locations. Here's everything you need to know about using it effectively:
Key Locations for Code Insertion:
- Header: Adds code within tags on all pages
- Footer: Places code before tag on all pages
- Lock Page: Displays code above password field on lock screen
- Order Confirmation Page: Shows on gift cards/memberships checkout completion
- Order Status Page: Appears after physical products/digital downloads checkout
Important Guidelines:
- Wrap JavaScript in
- Use Custom CSS editor instead of code insertion for styling
- Ajax loading may prevent CSS from loading properly
- Checkout page doesn't support custom code
Integrating with Cookie Banner:
- Enable Cookie Banner in [Cookies and Visitor Data] panel
- Choose [Opt-In and Opt-Out] for visitor consent options
- Add required integration code
- Save changes

Warning mark in red circle
Available Order Page Tags:
- {orderId} - Order number
- {orderSubtotal} - Order subtotal
- {orderSubtotalCents} - Subtotal in cents
- {orderGrandTotal} - Total order amount
- {orderGrandTotalCents} - Total in cents
- {customerEmailAddress} - Customer's email
Page-Specific Code Insertion:
- Access page settings
- Open Advanced Settings
- Add code to Page Header or Blog Post Item sections
Safety Considerations:
- Disable scripts in preview when troubleshooting
- Test custom code in incognito/private window
- Remove problematic code temporarily while debugging
- Follow best practices for third-party customization
Remember to always backup your code before making changes and test thoroughly before publishing to ensure functionality.