> For the complete documentation index, see [llms.txt](https://spreadapi.roombelt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://spreadapi.roombelt.com/examples/404-reporting.md).

# 404 errors reporting

Imagine you own a company website. Over the time the structure of your page changes (redesign?) and some pages are either deleted or moved to another URLs.  Unfortunately it's so easy to forget configuring redirect for some of these pages and that leads to the 404 (not found) screens. If you knew what pages you're missing you could redirect them to the proper URLs in seconds.

You can easily monitor what pages are missing on your site by adding the following snippet to the 404 (not found) page HTML. The exact steps to edit this page source code depend on your web server or hosting provider but each of them should have this option.

```markup
<script>
var spreadApiURL = 'TODO'; // Read further to get the URL
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("post", spreadApiURL);
xmlHttp.send(JSON.stringify({
    method: "POST",
    sheet: "entries",
    payload: {
      time: new Date().toISOString(),
      url: document.location.href,
      referrer: document.referrer
    }
  })
);
</script>
```

The only thing missing in the above script is the value of variable `spreadApiURL`. To get this URL first create a spreadsheet with the following structure (single sheet called *entries* with columns *time, url* and *referrer*):

![](/files/-Lv0_obuqAm7kustVkE7)

Next, follow the [setup instructions](/setup.md) to configure API for your spreadsheet. While configuring authentication add the following line to the script so that everybody can add an entry to your sheet.

```javascript
User("anonymous", UNSAFE(""), { entries: POST });
```

Now simply put the Web App URL provided to you during the deployment step as a value of variable `spreadApiURL` and you are done!

Keep in mind that you can use all the power of Google Sheets to analyze your data! E.g. you can create an ordered list of URLs reported most frequently.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://spreadapi.roombelt.com/examples/404-reporting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
