File DA-012 View as Markdown

Squarespace

This page adds Double Agent to a Squarespace site with Code Injection. It takes a few minutes and no code editing.

Before you start: Code Injection needs a Core, Plus or Advanced plan, or one of the legacy plans that include it.

Add the snippet

  1. Go to Settings › Website Tools › Code Injection. If you can't find it, search "code injection" in the settings search.
  2. Paste these two lines into the site-wide Header field:
<script>window.doubleagent=window.doubleagent||{q:[],push(){this.q.push(arguments)}};</script>
<script async src="https://cdn.doubleagent.so/v1/doubleagent.js" data-profile="auto"></script>
  1. Click Save.

Use the site-wide Header, not a single page's injection, or only that page is covered. Squarespace doesn't run injected code on its checkout pages, so checkout isn't covered.

Check it worked

Open your live site (not the editor) and run:

npx @doubleagent-so/cli verify https://your-site.example

It should end with Installed correctly. You can also open the browser console on the live site and run await doubleagent.ready() to see a verdict.

Optional: a token on your form

If a form on your site sends to your own server (not to Squarespace), you can add a signed token to it. Your server then checks the da_token field (verify tokens on your server). This needs your public key in the snippet (data-key="pk_live_…", see Capabilities). Add this to the Footer field:

<script>document.addEventListener('DOMContentLoaded', function () { doubleagent.push('protect', 'form', 'lead_form'); });</script>

'form' is a CSS selector for the first form on the page; use a more exact one if you have several.

Next: claim your domain to see your visitors.