Install on Squarespace
A header Code Injection entry counts every page on the site, including pages you add later.
Before you install
- Code Injection is unavailable on the Personal plan trial: upgrade before you paste anything.
- Your site must be published. On an unpublished site the box can look saved while no visitor ever receives the snippet.
Before you paste anything
Every snippet below shows YOUR-SITE-ID
. Replace it with your own site id, which is on the Tracking Code page of the site in your account.
If you do not have an account yet, creating one and adding your domain takes about a minute.
Add the snippet to Code Injection
- In your Squarespace dashboard, go to Settings, then Advanced, then Code Injection.
- Paste the snippet into the Header box.
- Save, then open your live site in a new tab.
<script>
(function () {
// Ensure this only runs in a browser environment.
if (typeof window === 'undefined' || typeof document === 'undefined') {
return;
}
var siteId = 'YOUR-SITE-ID';
var trackingDomain = 'www.veritametrics.com'; // 1. Initialize the Async Command Queue
// This ensures window.verita() is available immediately.
window.verita =
window.verita ||
function () {
(window.verita.q = window.verita.q || []).push(arguments);
};
window.verita.l = new Date().getTime(); // 2. Load the enhanced tracker script asynchronously.
// It will process the command queue once loaded.
var script = document.createElement('script');
script.src = 'https://' + trackingDomain + '/api/tracker.js?siteId=' + siteId;
script.async = true;
script.defer = true;
script.dataset.siteId = siteId;
script.dataset.trackingDomain = trackingDomain;
document.head.appendChild(script); // 3. Send the initial pageview using the *queue*
window.verita('trackPageView');
})();
</script>
<noscript>
<img
src="https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID"
referrerpolicy="unsafe-url"
alt=""
width="1"
height="1"
style="display: none"
aria-hidden="true"
/>
</noscript> Note: The box can look saved either way, so check a page on your live domain in a private window rather than inside the Squarespace editor.
Check that the data is arriving
- Open your site in a browser and load any page.
- In VeritaMetrics, open the site and click Tracking Code in the sidebar. The status turns active and your visit appears in the recent-pageviews list within a few seconds.
If you're comfortable checking yourself: open your browser's developer tools (right-click the page and choose Inspect, or press F12), open the Network tab, and reload. A working install shows a request to /api/tracker.js succeed (status 200), then a second request when you move the mouse or scroll.
Ajax loading can report every visit as a single page
Squarespace turns on Ajax loading by default on 7.0 sites, and it cannot be turned off on the Skye family or on the Farro family's blog landing page. Squarespace's own help centre says Ajax loading can log hits on the first page only. We have not confirmed whether it updates the URL in a way our tracker can follow. If your dashboard shows one pageview per visit no matter how many pages someone reads, that is the likely cause: turn off Ajax loading where your template allows it, or contact us and we will check your site.
Guides for other platforms
The same install, on a different stack.
Explore the documentation
Jump to another guide.