# Install on Mintlify

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

Add a small analytics.js file to your Mintlify docs folder.

Mintlify doesn't take a `<script>` tag directly. Instead, it loads every `.js` file found in your docs folder on all pages. You add one small file that loads the analytics script.

**1. Copy the code**

In the portal, open **Settings → Install** and choose **Mintlify**. Copy the code shown. It looks like this, with your own site key:

```js
(function () {
  var s = document.createElement('script');
  s.defer = true;
  s.src = 'https://analytics.writechoice.io/s/YOUR_SITE_KEY.js';
  document.head.appendChild(s);
})();
```

**2. Create analytics.js**

In your docs repository, create a file named `analytics.js` in the docs folder, next to `docs.json`, and paste the code into it.

**3. Publish**

Commit and push. Mintlify publishes the change with your next deployment. Then [check that it works](https://analytics.writechoice.io/docs/install/#check-that-it-works).

## Notes

- The file name doesn't matter, as long as it ends in `.js` and sits inside the docs folder.
- Don't paste a `<script src="...">` tag into an MDX page: Mintlify's documentation advises against it. Use the `.js` file instead.
- Mintlify is a single-page application: moving between pages doesn't reload the browser. The script records a pageview on each navigation, so you don't need to listen for Mintlify's navigation events yourself.
- The file applies to the whole site. It can't be limited to some pages.
- To add a [tag](https://analytics.writechoice.io/docs/install/events-and-tags/#tags), add `s.setAttribute('data-tag', 'v2');` after the `s.src` line.

## Heatmap preview

Sites hosted by Mintlify only allow being shown inside Mintlify's own dashboard, so the **Heatmaps** tab draws the clicks on a blank background. This can't be changed in `docs.json`: Mintlify changes the allowed origins on request. Email Mintlify support with your project subdomain, your documentation domain, the origins to allow (see [Heatmap preview](https://analytics.writechoice.io/docs/install/heatmap-preview/)) and what it's for. See Mintlify's help page [Embed your docs site in an iframe](https://www.mintlify.com/docs/help-center/embed-docs-site-in-iframe). If your docs are served through your own reverse proxy that sets the policy, change `frame-ancestors` there instead.

## Site search

The Mintlify search box is recorded automatically: the final search, the number of results shown, and the result the reader opens. Questions sent to the Mintlify assistant are not recorded by the snippet: they are what the [AI Reports](https://analytics.writechoice.io/docs/ai-reports/) look at.