# Install on WriteDocs

> For the complete documentation index, see [llms.txt](https://analytics.writechoice.io/docs/llms.txt).

Add the snippet to the scripts field of writedocs.json.

A WriteDocs site loads the scripts listed in the `scripts` field of `writedocs.json` on every page.

**1. Copy your script address**

In the portal, open **Settings → Install** and copy the address in the **HTML** line: `https://analytics.writechoice.io/s/YOUR_SITE_KEY.js`, with your own site key.

**2. Add it to writedocs.json**

Add it under `scripts.body` (scripts that load at the end of the page). If `writedocs.json` already has a `scripts` field, add the entry to its `body` list:

```json
{
  "scripts": {
    "body": [
      { "src": "https://analytics.writechoice.io/s/YOUR_SITE_KEY.js" }
    ]
  }
}
```

**3. Publish**

Commit and push (or publish from the WriteDocs editor). Then [check that it works](https://analytics.writechoice.io/docs/install/#check-that-it-works).

## Notes

- WriteDocs sites are single-page applications: the script records a pageview on each navigation, with nothing else to set up.
- The search box of WriteDocs sites is recorded automatically. See [Site search](https://analytics.writechoice.io/docs/install/events-and-tags/#site-search).
- To add a [tag](https://analytics.writechoice.io/docs/install/events-and-tags/#tags) (for a version or a language), load the script with `content` instead of `src`, so it can carry the `data-tag` attribute:

  ```json
  {
    "scripts": {
      "body": [
        { "content": "(function () { var s = document.createElement('script'); s.defer = true; s.src = 'https://analytics.writechoice.io/s/YOUR_SITE_KEY.js'; s.setAttribute('data-tag', 'v2'); document.head.appendChild(s); })();" }
      ]
    }
  }
  ```

- If the site asks readers for consent before analytics load (WriteDocs' consent banner), add `"consent": true` to the entry: the script then waits for the reader's answer.

## Heatmap preview

WriteDocs sites can be shown inside the portal, so the **Heatmaps** tab draws the clicks over the live page. Nothing to do.