Writing capture
Writing capture script
Writing capture records typing behavior on text fields and editors, so it can be replayed: keystroke timing, pauses, paste events, and deletions. Output is a per-session composition classification (Imported, Single Drafted, Substituted, Quoted, Original). Writing replay is currently available for US-region accounts only. This page covers the standalone writing capture script for sites that do not run the NotAI script. If the NotAI script is already installed, turn on writing capture there instead (see the install guide).
Overview
The standalone writing capture script is one file, /text-monitor/auto.js, served from cdn.isnotai.com. Add a single script tag with your configuration and it attaches to the supported editors on the page. There is nothing to install and no code to write.
For what writing capture does and does not collect, see the privacy policy.
When to use this
Use the standalone script if:
- Your site does not run the NotAI script.
- You want writing capture on a specific subset of pages. Add the script tag only to those pages.
Turn on writing capture in the NotAI script instead if:
- You are already running the NotAI script.
- You want behavioral analysis and writing capture from one install.
- You want automatic detection of the Canvas Rich Content Editor and other rich-text editors.
Do not load both the NotAI script and the standalone script on the same page.
Install
Add the script tag to every page where people write. It reads its configuration from the data-config attribute and attaches to supported editors once the page has loaded.
<script
src="https://cdn.isnotai.com/text-monitor/auto.js"
data-config='{"integrationId":"a7f3c2e1","region":"us"}'
async></script>
For custom editors not covered by the default selectors, pass extraSelectors:
<script
src="https://cdn.isnotai.com/text-monitor/auto.js"
data-config='{"integrationId":"a7f3c2e1","region":"us","extraSelectors":[".my-editor"]}'
async></script>
To close the writing session when the user submits, turn on finalizeOnSubmit. With true, an editor's session closes when the form that contains the editor is submitted, or when the user clicks a standard submit control anywhere on the page. The click check is page-wide: on a page with several unrelated forms, one submit closes the session of every monitored editor. In that case, pass selectors scoped to your own form instead:
<script
src="https://cdn.isnotai.com/text-monitor/auto.js"
data-config='{"integrationId":"a7f3c2e1","region":"us","finalizeOnSubmit":["#essay-form button[type=submit]"]}'
async></script>
Selectors you pass replace the standard click list. Submitting the form that contains the editor still closes its session. If the user returns to the editor after a submit, the next time they focus it or type in it a new writing session opens.
The script attaches to the editors on the page when it has loaded. On Canvas pages it also picks up editors that appear later. On other sites, an editor added after load (for example by a single-page-app route change) is not monitored until the next page load.
Options
All options go in the data-config JSON.
| Option | Type | Required | Description |
|---|---|---|---|
integrationId |
string | Yes | 8-character hex, from your dashboard. See Integration ID. |
region |
string | Yes | "us" or "eu". Must match the region on your account. See Regions. |
extraSelectors |
string[] | No | CSS selectors for additional custom editors beyond the standard set. |
finalizeOnSubmit |
boolean | string[] | No | Default off. true closes an editor's writing session when its form is submitted, or when a standard submit control anywhere on the page is clicked: button[type="submit"], input[type="submit"], button.submit_button, button[data-action="submit"]. A non-empty array of CSS selectors replaces that click list. The click check is page-wide; see Install. |
correlationId |
string | No | Opaque caller-supplied tag (up to 256 chars) attached to every writing session the script opens. Useful for tying your own row IDs or submission IDs to the captured session. |
autoBeaconClose |
boolean | No | Default true. On pagehide, sends pending events and closes active writing sessions. On beforeunload, only sends pending events, because the user can still choose to stay on the page. |
Supported editors
The script attaches to these editor surfaces automatically and picks the right adapter for each:
<textarea><input type="text">- Any element with
contenteditable="true" - Quill editor instances
- TinyMCE editor instances
If you use a different editor, add its root container selector to extraSelectors. Anything that is not one of the specialized adapters above falls back to universal content diffing.
Self-hosted script
Some customers want to serve NotAI from their own origin because adblocker lists block well-known third-party domains. The dashboard does not package this standalone script for self-hosting. On Enterprise plans it builds the NotAI script for you with writing capture turned on, and that file replaces this script on your pages (never run both on one page). The file is served from your site, but it still loads the writing capture code from cdn.isnotai.com: a filter that blocks that host still stops writing capture, so allow it.
The setup is self-service from your dashboard:
- In your dashboard, open Settings, then Custom Domains. To report through your own subdomain (for example,
verify.example.com), add it under Custom ingest domains: the dashboard shows the DNS records it needs, a CNAME and verification records. - Create those records with your DNS provider. The dashboard checks them and marks the domain active once they are live. (A custom domain is optional: the file can also report to NotAI's own hosts.)
- Under Self-hosted SDK, turn on writing capture, choose the file name, sampling and the reporting host (your active custom domain, if you added one), then choose Generate SDK file and download the file. Your integration ID and region are baked in.
- Host the file on your own CDN. Your install tag becomes a single script with no
data-*attributes:
<script src="//your-cdn.example.com/analytics.js" async></script>
The file carries its own settings (file name, sampling, writing capture, reporting host). To change them, generate a new file in the dashboard and host it in place of the old one.
Integration ID
Every NotAI deployment is identified by an 8-character hexadecimal integration ID (for example a7f3c2e1). Copy yours from Integrations in your NotAI dashboard.
The integration ID is public by design: it identifies which account receives the session data. It does not authenticate the sender, and a leaked integration ID does not expose account data. Sessions are accepted only from origins on your integration's allowed origins list (in the dashboard, open Settings, then Pixel Install, then Allowed Origins, or the integration's own page).
Regions
NotAI operates two data regions: US and EU. Pick the region that matches your account.
- US accounts: set
"region":"us". - EU accounts: set
"region":"eu". Your site must also allow the EU reporting hosts in its Content Security Policy (see below). Writing replay is currently available for US-region accounts only.
A session sent to the wrong region will be rejected.
Content Security Policy
What your policy needs depends on how you load the script:
- CDN script. Allow
https://cdn.isnotai.cominscript-srcand your region's reporting hosts inconnect-src. The blocks below show the full policy. - Self-hosted script. A file built with a custom ingest domain reports to that domain, not the reporting hosts shown below: allow the domain shown under Settings, then Custom Domains in your dashboard in
connect-src, and keephttps://cdn.isnotai.cominscript-src, where the file loads the writing capture code from.
Pick one regional block. Never combine.
US
script-src 'self' https://cdn.isnotai.com;
connect-src 'self' https://chl.isnot.ai wss://chl.isnot.ai;
EU
script-src 'self' https://cdn.isnotai.com;
connect-src 'self' https://chl-eu.isnot.ai wss://chl-eu.isnot.ai;
If you already have the CDN host in script-src for other assets, only the region-specific connect-src line is new.
Troubleshooting
Monitor is not capturing
- Confirm
integrationIdandregionare correct for your account, and thatdata-configis valid JSON. The script logs an error in the browser console when it cannot read its configuration. - Ensure your page's origin is on the allowed origins list for your integration. Add origins in your dashboard: open Settings, then Pixel Install, then Allowed Origins, or on the integration's own page. Requests from origins outside the list are rejected.
- Verify your Content Security Policy allows the hosts for your region (see above).
- Check the editor is one of the supported surfaces, or add its selector to
extraSelectors. - Outside Canvas, check the editor was on the page when it finished loading. Editors added later are not picked up.
CSP violations in the browser console
- Confirm you are using the CSP block for your account's region, not the other one.
- If the script is blocked, add
https://cdn.isnotai.comtoscript-src. - If the reporting connection is blocked, add the regional host to
connect-src.
Moving from the npm package
The @isnotai/text-monitor npm package is no longer distributed. Remove the package and its createMonitor and attach calls, then add the script tag from Install with the same integrationId and region.
The script is not a drop-in replacement for an integration that attached and detached editors at runtime. It has no runtime API, and outside Canvas it monitors only the editors on the page when it loads. If your editors mount later, contact support before you switch.
Still stuck? Support usually replies within a business day.
Contact support