Squarespace Code Injection: Adding a Tracking Tag to Every Page

Most analytics, heatmap and pop-up tools give you a short script and ask you to put it in the <head> of every page. On Squarespace, the tool for that is code injection, and specifically its Header field. This guide covers the plan requirement Squarespace documents today, where the panel lives on version 7.1 and 7.0 sites, which of the several injection fields to use (and which to avoid), and how to confirm the tag works without being misled by the site editor.

Updated

Before you start: check your plan

Code injection is not on every Squarespace plan. Squarespace's help article states: "Code injection is available in the Core, Plus, Advanced, and some legacy billing plans." Its premium features article adds that "Premium features aren't available on the Basic plan," and that if you downgrade to Basic, "Code injection is disabled."

Your situationCan you use site-wide code injection?Source
Core, Plus or Advanced planYesSquarespace: code injection article
Some legacy billing plansPossibly. Squarespace says "some legacy billing plans" include it, depending on when you signed up.Squarespace: code injection and premium features articles
Basic planNo. Premium features, including code injection, aren't available.Squarespace: premium features article
Free trialSquarespace says trials get "most premium features" but doesn't name code injection specifically. Check in your own trial before you rely on it.Squarespace: premium features article

Plan names change over time, so look at the plan shown in your own site's billing settings rather than relying on an older tutorial. If the Code Injection panel asks you to upgrade, that is your answer.

Two more things to have ready:

  1. Your snippet. Copy it straight from your tool's dashboard. In marketingLABO, for example, you register your site with its name and URL, and the dashboard shows your tracking tag with a Copy tag button and the instruction to paste it right before </head> on every page. On Squarespace, the Header field of code injection is that spot.
  2. Your site version. Squarespace sites run on version 7.1 or the older 7.0. The menus differ, as shown in Step 1. If you don't know your version, the menus you see will usually tell you.
Throughout this guide we use a placeholder: <script src="https://...your tag..."></script>. Always paste the exact snippet from your own tool's dashboard, not this example.

The code injection fields, and which one you need

Squarespace has several places to inject code. For a tag that has to run on every page, only one of them is right. Here is what each field does, according to Squarespace's help center:

FieldWhere the code ends upUse it for a site-wide tracking tag?
Header (site-wide)"Code added here is injected into the <head> tag on every page in your site."Yes. This is the one.
Footer (site-wide)Before the closing </body> tag on every pageOnly if your tool asks for the footer.
Lock PageAbove the password field on password-protected sites and pagesNo.
Order Confirmation / Order StatusPages shown after checkout, with special order variablesNot for a page tag. These are for order-specific scripts.
Page Header Code Injection (per page)The <head> of one pageNo. It only covers that page.
Post Blog Item Code InjectionEvery post in one blogNo.

The per-page fields are tempting because they are right there in the page settings, but a tag that should run "on every page" belongs in the site-wide Header field. If you put it in one page's settings, every other page goes untracked.

Step 1: Open the Code Injection panel

Squarespace's Pages panel article describes the current layout: "Click Custom Code at the bottom of the panel to add custom CSS, HTML, and other code to your site." Custom Code contains two tools, Custom CSS and Code Injection.

Site versionPath to Code Injection
Version 7.1Open the Pages panel, scroll to the bottom, click Custom Code, then Code Injection.
Version 7.0Squarespace says: "If your site is on version 7.0, click Website Tools to find these options." Then choose Code Injection.

Squarespace has moved this panel more than once over the years, so screenshots in older tutorials may not match your screen. The code injection help article also contains an "Open the Code Injection panel" link that takes you there directly after you pick your site, which is handy if you can't find the menu.

You can open the Pages panel from the Squarespace app too (tap More, then Pages), but pasting code is much easier on a computer.

Step 2: Paste the tag into the Header field

In the Code Injection panel, click into the Header field. If there is already code there (from analytics, a chat widget or site verification), don't delete it. Click at the very end of the existing code, press Enter to start a new line, and paste your snippet there.

<!-- Tracking tag: added 2026-10-12 -->
<script src="https://...your tag..."></script>

A few rules keep this safe:

  1. Scripts need script tags. Squarespace's instructions say to wrap JavaScript in <script></script> tags. Vendor snippets almost always include them already; don't strip them out.
  2. Paste, don't retype. A single missing quote can stop a script from running.
  3. Don't paste inside another snippet. Each tool's code gets its own lines, never inside someone else's <script> or <style> block.
  4. Add a comment. An HTML comment with the tool name and date tells your future self, or a designer, what the code is for.
  5. Paste it once. If the tool is already installed another way, a second copy can double your page views.

Step 3: Save

Click Save. Code injection applies to your live site, so the change reaches visitors right away. Nothing else needs publishing.

Keep in mind Squarespace's warning on the same page: "Custom code might break your site's appearance or behavior." A typical tracking tag doesn't change how your site looks, but if something does look wrong after saving, remove the snippet, save again, and contact the tool's provider.

Step 4: Test in a private window, not in the editor

This is where many people get confused. The view you see while logged in to Squarespace is not a reliable test, because Squarespace may disable custom code inside the site editor.

Squarespace explains that custom code can interfere with secure editing, so you may be asked to disable it. If the preview shows an error, Squarespace offers a Disable Scripts in Preview button. When scripts are disabled, a banner appears with an Enable Scripts in Preview button. That banner can't be hidden, but it only appears while you're logged in, and it doesn't change what visitors see.

Squarespace's own advice for checking the live site with code enabled is to open the URL in a private or incognito window. So test like this:

  1. Open your site in a private window at its public address.
  2. Accept the cookie banner if your site uses one and you've set the tag to depend on consent (see below).
  3. View the page source (Ctrl+U on Windows, Option+Cmd+U in Chrome on Mac) and search for a recognizable part of your snippet, such as its domain. It should appear inside the head.
  4. Click through several page types: the home page, a regular page, a blog post and, if you sell, a product page.
  5. Use your tool's own check. In marketingLABO, open any page of your site, then press Check tracking in the dashboard. If nothing has arrived, the dashboard suggests confirming the tag is right before </head> on every page and your changes are saved, then reloading your site and trying again.

After browsing for a minute, look for your own visit in the tool. In marketingLABO, the visitor history timeline should list each page you opened. If you see only the first page and your site is on version 7.0, see the note on Ajax loading below.

Version 7.1 vs 7.0: details that matter

Squarespace's code injection article lists version-specific behavior. The points that affect a tracking tag:

TopicVersion 7.1Version 7.0
Where to find Code InjectionPages panel > Custom CodeWebsite Tools
Per-page header injectionSquarespace advises against adding HTML here, because it disappears if header transparency is turned offDoesn't appear on Index landing pages
Ajax loadingNot mentioned"Ajax loading may prevent CSS added to code injection from loading correctly." Squarespace suggests the CSS Editor for CSS.

Squarespace's Ajax note is about CSS, not scripts. Still, if your 7.0 template loads pages with Ajax, a quick test is worthwhile: click from page to page in a private window and confirm that your tool records each page, not just the first. If it doesn't, check your template's settings and ask your tool's provider how they handle it.

Commerce sites: checkout and order pages

If you sell on Squarespace, know where your tag can run. Squarespace states: "Checkout pages don't support code." A tag in the Header field covers your storefront pages, product pages and content, but not checkout.

The Order Confirmation and Order Status fields exist for scripts that need order details. Squarespace provides variables such as the order ID, subtotal, grand total and customer email for those fields, and suggests wrapping a script in a first-page-view condition so it runs only right after checkout. These are meant for tools that accept order data in that form.

marketingLABO doesn't read order data: it has no Squarespace integration and doesn't see cart contents, order values or payments. Don't paste the marketingLABO tag into the order fields expecting purchase tracking. Use Squarespace's own Commerce reports for revenue and orders, and use page-level data for what happens before checkout: where visitors come from, which product pages they read and where they leave. Our guide to cart abandonment covers that pre-checkout view.

Cookie banners and consent

Squarespace has a built-in cookie banner, and its code injection article notes that if you use the banner, you can use code injection to adjust third-party integrations based on whether visitors accept cookies. Squarespace also notes that its built-in Google Analytics integration doesn't need code here.

What that means in practice: a tag pasted plainly into the Header field runs for every visitor. If your consent setup requires analytics or marketing tags to wait until a visitor accepts, you will need code that checks the visitor's choice before loading the tag, following Squarespace's documentation. That is an advanced edit; get help from a developer or a Squarespace Expert if you aren't comfortable with JavaScript.

marketingLABO doesn't include a cookie consent tool. Decide your consent approach with your own privacy advisor. This guide describes Squarespace's features, not legal advice.

If the tag doesn't load: troubleshooting

SymptomLikely causeWhat to do
Code Injection asks you to upgradeYour plan doesn't include code injection (for example, Basic)Upgrade to a plan that includes it, or check your legacy plan's features.
Snippet works in a private window but not while you're logged inScripts are disabled in previewNormal. Test in a private window; visitors aren't affected.
Snippet appears on one page onlyIt was pasted into Page Header Code InjectionMove it to the site-wide Header field and remove the per-page copy.
Snippet isn't in the page source at allNot saved, wrong site, or pasted in the wrong fieldReopen Code Injection, confirm it's in Header, and save.
Tool stopped working after a plan changeSquarespace disables code injection after a downgrade to BasicCheck your plan.
Snippet present, tool shows nothingA browser extension blocking scripts, a typo, or a mismatched site URL in your toolTry a browser without blockers, re-copy the snippet, and check the site URL registered in your tool.
Site editor shows errors after adding codeCustom code is interfering with editingUse Disable Scripts in Preview, or add /safe right after /config in your editing URL, as Squarespace describes.

If Safe Mode doesn't help, Squarespace suggests temporarily removing code from each area where you added it, then testing again. Note that Squarespace says adding code "falls outside the scope of Squarespace support"; for problems with a vendor's script, contact the vendor, the Squarespace forum or a Squarespace Expert.

Keeping your Header field tidy over time

The Header field tends to collect code. A verification tag from one year, a chat widget from another, a heatmap tool someone trialed and forgot. Every script in it loads for every visitor on every page, so a little housekeeping pays off.

  1. Label every snippet. One comment line per tool, with the tool name, who added it and when. When nobody remembers what a script does, the comment is the only clue.
  2. Keep a copy outside Squarespace. Before you edit the field, copy everything in it into a text file or shared doc. If something goes wrong, you can paste the old version back in seconds.
  3. Review it a few times a year. Remove snippets for tools you no longer use. If you aren't sure whether a tool is still active, check whether anyone still logs in to it and whether it still receives data.
  4. Change one thing at a time. Add or remove a single snippet, save, test in a private window, then move on. If several changes go in together and something breaks, you won't know which one caused it.
  5. Re-check after big site changes. After a plan change, a move between site versions or a redesign by an agency, open the Header field and confirm your snippet is still there, then run your tool's tracking check.

If you work with a designer or agency, tell them which snippets are in the Header field and why. A well-meaning cleanup during a redesign is one of the most common ways tracking disappears without anyone noticing, and the gap usually shows up weeks later as a sudden drop in your reports.

It also helps to note, in the same doc, the date you installed each tool. When you compare periods in your reports, you will know which dates have data from that tool and which don't.

What a head tag can do on Squarespace

Once the tag loads on every page, a page-level tool sees what visitors do on those pages. With marketingLABO on a Squarespace site:

  1. Analytics and heatmaps. Reports by traffic source, page and conversion, plus per-page heatmaps of time on page, scroll depth and clicks. Our guide to website heatmaps explains how to read them.
  2. Visitor history. A per-visitor timeline of the pages they viewed.
  3. Micro-conversions. Count goals by pages viewed, a specific URL, time on page or return visits.
  4. Pop-up banners. Show banners immediately, after a delay, at a scroll depth or on exit intent, targeted by page URL, visit count, days since last visit, pages viewed or not viewed, and traffic source.
  5. Forms. Build forms with a drop-off report per field. If people start your forms and quit, see our guide to form abandonment.

Common mistakes

MistakeWhat happensFix
Testing while logged inScripts may be disabled in preview, so the tag looks broken.Test in a private window.
Using the per-page field for a site-wide tagOnly one page is tracked.Use the site-wide Header field.
Deleting existing Header code to "make room"Other tools stop working.Add your snippet on a new line after existing code.
Stripping the <script> tagsCode shows up as text or doesn't run.Paste the snippet exactly as given.
Expecting the tag to run in checkoutSquarespace checkout pages don't support code.Use Commerce reports for orders.
Downgrading to BasicCode injection is disabled.Stay on a plan that includes it.
Installing the same tool twiceDouble page views.Keep one copy per tool.

Quick checklist

  1. Plan includes code injection (Core, Plus, Advanced or a qualifying legacy plan).
  2. Code Injection opened from Pages > Custom Code (7.1) or Website Tools (7.0).
  3. Snippet pasted into the site-wide Header field, on its own line, after any existing code.
  4. Comment added with the tool name and date. Saved.
  5. Verified in a private window on several page types, plus your tool's own tracking check.
  6. Consent approach decided if your site uses a cookie banner.
  7. Expectations set: checkout pages don't run code.

FAQ

Can I use a code block instead of code injection? A code block sits on one page, so it doesn't cover your whole site. Squarespace also says JavaScript in code blocks requires the Core plan or higher (or some legacy plans). For a tag that must be on every page, use the Header field.

Header or Footer? Follow your tool's instructions. marketingLABO asks for the head of every page, which is the Header field.

Do I need to republish after saving? No. Saving code injection updates the live site. Check it in a private window.

Is it the same on Wix, Shopify or WooCommerce? The goal is the same, the steps aren't. See adding custom code to the head of a Wix site, adding a tracking script to Shopify and adding a script to the head of a WooCommerce store.

marketingLABO's Free plan includes one site with analytics, heatmaps and visitor history, plus one form and one pop-up banner, with no time limit and no credit card required. Compare plans in the pricing section, or sign up free to get your tag.

Sources

All checked on October 12, 2026.

  1. Squarespace Help Center: Customize parts of your site with code injection
  2. Squarespace Help Center: The Pages panel
  3. Squarespace Help Center: Premium features
  4. Squarespace Help Center: Add custom code to your site

Start free — no credit card needed

Sign up free