How to add analytics to a Squarespace site with Code Injection
Squarespace already counts your visitors, with cookies of its own. A second tool's tag goes in Code Injection's Header field, on Core or above, and on older 7.0 templates with Ajax loading only a logged-out test shows whether every page gets counted.
In this article
- 1What Squarespace already counts
- 2When a second tool is worth adding
- 3Check your plan first
- 4Find your version, then the panel
- 5Paste the tag into Header
- 6Not in a page's settings or a code block
- 7Older templates: Ajax loading
- 8Test it the way a visitor sees it
- 9If the numbers look wrong
- 10Squarespace's own cookies
- 11The short version
Squarespace counts your visitors on its own, so a second analytics tool is a choice, not a requirement. If you want one, its script goes into Code Injection, which needs a Core plan or above. And on some older templates, a setting that can leave every page but the first uncounted is switched off while you're logged in, so a test you run as yourself won't show it.
This guide covers what Squarespace already counts, where the script tag goes, and how to test it so the result matches what visitors get. The steps work for any analytics tool that installs with a script tag. The Squarespace details come from its help center, as of November 2026.
What Squarespace already counts
Every Squarespace site has an Analytics panel. According to Squarespace's overview, it has reports on traffic, traffic sources, geography, site content, search keywords and form and button conversions, and for a store, sales, the purchase funnel and abandoned carts. Which of them you see depends on your plan and on whether a payment processor is connected.
A few details matter when you compare it with another tool later:
- It counts with cookies. Squarespace's cookie list has five analytics cookies, among them
ss_cvr, which lasts two years, andss_cvt, which lasts 30 minutes. Its traffic report ends a visit when the 30-minute cookie runs out, and ends every visit at midnight. - It leaves you out while you're logged in. Squarespace says its analytics ignores your activity while you're logged in, and counts you like any other visitor once you log out.
- It stays inside Squarespace. Data can take up to three hours to refresh, and the reports can't be exported.
When a second tool is worth adding
A separate tool earns its place when it answers a question Squarespace's doesn't:
Several sites in one place
If this site is one of several, on Squarespace and elsewhere, one dashboard for all of them is easier than a different report on each platform.
Analytics without Squarespace's cookies
You can restrict Squarespace's non-essential cookies, but its cookie page warns that its analytics then isn't a complete or accurate picture: each pageview counts as its own visit. A tool that counts without cookies has no cookie to lose.
Your figures outside Squarespace
Squarespace's analytics reports can't be exported. If you want the numbers in a spreadsheet or another app, check that the tool you pick lets you get them out.
Visits from AI assistants as one group
As of November 2026, Squarespace's Traffic sources panel has no channel for AI assistants, so visits from ChatGPT, Claude, Perplexity and the others sit among the other referrers. The guide to tracking ChatGPT traffic shows how to find them in any tool.
Check your plan first
As of November 2026, Squarespace's code injection page says it's available on the Core, Plus and Advanced plans and some legacy billing plans. Basic isn't on the list. On Basic, code blocks take HTML, Markdown and CSS but not JavaScript, so there's no way to run a script tag across the site. If a site moves down to Basic later, Squarespace's premium features page says code injection is disabled, and the tag in it stops counting.
On a trial, Squarespace notes that the site isn't public yet, so a tag would have little to count. Test it once the site is live.
Google Analytics is the exception: it doesn't need Code Injection. Squarespace has a field for the measurement ID under Developer tools → External API keys, and its help page pairs it with the site's cookie banner.
Find your version, then the panel
A Squarespace site runs on version 7.1 or the older 7.0, and the menus differ. The bottom of the Pages panel shows which version and template your site uses. Then:
- Open the Pages panel.
- On 7.1, click Custom Code at the bottom of the panel, then Code Injection. On 7.0, click Website Tools, then Code Injection.
The panel has fields for Header, Footer, the lock page and the order confirmation and order status pages. Only Header and Footer run on every page of the site.
Paste the tag into Header
Sign up for the tool you picked, add your site using the domain visitors actually see, and copy the snippet it gives you, usually a single <script> tag shaped roughly like this:
<script defer src="https://analytics.example.com/script.js" data-site="YOUR-SITE-ID"></script>That's a placeholder, not a working tag. Copy the exact one from your tool and don't change its attributes. Then:
- Paste the tag into Header. Squarespace puts Header code inside the
<head>of every page. Footer code goes just before the closing</body>, on every page too. Use it only if your tool asks for it. - Click Save.
If the field already holds other code, paste the tag on a line of its own, outside any other <script> or <style> block. Squarespace's support team says it can't help add custom code or troubleshoot it, so for a tag that misbehaves, your analytics tool's own help is the place to ask.
Not in a page's settings or a code block
Squarespace has other places that take code, and none of them suits analytics:
- Page Header Code Injection, opened from a page's gear icon in the Pages panel, then Advanced, adds code to that one page's
<head>. - Post Blog Item Code Injection, in a blog page's settings, adds code to every post of that blog, in the body next to the post rather than in the head.
- A code block runs where it sits, on one page, and needs Core or above for JavaScript.
Each of them leaves the rest of the site uncounted, and the same tag there and in Header can load twice on that page. Checkout pages are a case of their own: Squarespace doesn't allow custom code on them at all, so no script-tag tool sees them. For a store, the Purchase funnel and Abandoned cart reports in Squarespace Analytics cover that step.
Older templates: Ajax loading
Some 7.0 templates load pages with Ajax: the header and footer don't reload from page to page, so the rest of the content appears sooner. According to Squarespace's page on it, that's Brine, Farro, Skye (on its blog landing page), Tremont and York, with Ajax on by default. The same page warns that Ajax “can also interfere with site analytics, logging hits on the first page only.” Two details make it easy to miss:
- It's always off while you're logged in. Click through the site as yourself and every page loads in full, so the problem never shows.
- It can't always be switched off. To turn it off, open Site styles, search for Enable Ajax loading and uncheck it. On Skye it can't be disabled, and on Farro the blog landing page keeps using Ajax either way.
Version 7.1 has no Ajax loading. On a 7.0 template that has it, test as a visitor would: logged out, moving from page to page with the site's own links. Some analytics tools also count a page change that swaps the address without a full reload, the way single-page apps work. If yours doesn't, expect what Squarespace warns of: hits on the first page only.
Ajax is off while you're logged in, so a test you run as yourself can't show the problem.
Test it the way a visitor sees it
Squarespace's own advice for seeing a site with its code running is a private or incognito window. That also logs you out, which matters here twice: Ajax only runs for visitors who aren't logged in, and while you are, Squarespace always shows the built-in domain (the one ending in squarespace.com) in the address bar, even if you have a custom one.
- Open your custom domain in a private window, with any ad or tracker blocker turned off for the test.
- View the page source and search for the script's address. It should be in the
<head>. If it isn't, check that you saved, that the tag went into the site-wide Header field, and that your plan includes code injection. - Open the developer tools, go to the Network tab and reload. Filter by your tool's domain. You should see the script load, and usually a second request that sends the pageview. Some tools answer a pageview they discard, from a domain they don't expect for example, with the same success status, so this step shows the request left, not that it counted.
- Open the tool's live or real-time view, if it has one, and look for your visit.
- Click through three or four pages using the site's own links, and check that each one shows up as its own pageview.
The built-in domain is worth a thought when you set up the tool. Squarespace says it won't redirect to your custom domain, so a visitor who lands on it stays there, while secondary custom domains redirect to the primary one. Register the primary domain in your tool. If the tool only counts the domain you registered, visits to the built-in address won't appear.
If the numbers look wrong
- Nothing in the page source. The change wasn't saved, the tag went into one page's settings, or the plan doesn't include code injection.
- In the source, but nothing loads. A blocker stopped it, or the tag broke on the way: curly quotes, a missing
</script>, or the tag pasted inside another script. - Only the first page of each visit counts. Most likely a 7.0 template with Ajax loading. Turn it off where Squarespace lets you.
- Everything counted twice. The tag is in Header and also in a page's header field, a blog's post field or a code block. Remove one.
- The editor stops working after you paste. Squarespace has a Disable Scripts in Preview button for that, or you can add
/safeafter/configin the editing address. It only changes your logged-in view, not what visitors get. - Your own visits in the numbers. Squarespace Analytics leaves you out while you're logged in. A tag in Code Injection can still run in the editor's preview, so unless the tool only counts your custom domain, your editing may show up.
- Squarespace and the other tool disagree. They will. Squarespace recognises returning visitors with cookies, some of which last two years, and a cookie-free tool has to do it some other way, each with its own blind spots, as how to count unique visitors without cookies explains. Check that both rise and fall on the same days, and read why no two analytics tools agree on your traffic for the rest.
Squarespace's own cookies
A cookie-free analytics tag doesn't add analytics cookies, but Squarespace still sets its own: necessary cookies that vary with the features a site uses, and the analytics cookies above unless you restrict them. Without a banner, that's the Cookies & visitor data panel: switch off Cookie Banner, then under Advanced Privacy settings set Non-essential Cookies to Restrict and save. Squarespace Analytics then counts each pageview as its own visit, as above.
To see what your live site stores, open it in a private window with the developer tools, clear the site data, browse a few pages and look under Cookies and Local storage. Embedded videos, maps, forms and other scripts can add their own. Whether you can do without a banner depends on that whole list, and what it takes to run a website without a cookie banner goes through it.
If you plan to send campaign traffic to the site, tag the links the same way from the first day. A small UTM naming system keeps those reports readable.
The short version
- Look at Squarespace Analytics first, and add a tool only for a question it can't answer.
- Check that your plan includes code injection: Core, Plus or Advanced, as of November 2026.
- Pages panel → Custom Code → Code Injection (Website Tools on 7.0) → Header, then Save.
- Not in a page's settings, a blog's post field or a code block as well.
- On a 7.0 template with Ajax loading, turn it off where you can.
- Test logged out, in a private window, on your custom domain, across several pages.
Lomen is one of the tools you could add this way, as one script tag in Code Injection's Header field, with no API key, package or build step. Pageviews only count from the domain you added and its subdomains, with or without www, so with your custom domain added, visits to the built-in squarespace.com address, where you browse while logged in, stay out of the numbers. A second copy of the tag for the same site does nothing, and the script also counts a page change that swaps the address without a reload, though on an Ajax template the click-through test is still the proof. Its standard script sets no cookies, never stores IP addresses and by default keeps nothing in the visitor's browser. It groups visits from nine AI assistants by referrer and utm_source, and the figures on its dashboard export to CSV. If your store takes payments through your own Stripe account, you can connect that account to Lomen with a read-only key, and it shows the revenue on the same chart as visitors, not split by product. It has no connection to Squarespace Commerce itself and no custom events or funnels, so for form and button clicks or the purchase funnel, Squarespace Analytics is the closer fit. Lomen is free during the public beta.