> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/how-the-apps-work/screens/staff/analytics.md).

# Analytics

{% hint style="info" %}
Draft, written by an agent and not yet checked by a person ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). Platforms: web. [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/screens/staff/analytics.md).
{% endhint %}

Staff pick a site and see where its tasks are, as pins on a map.

* **Where:** admin app `/analytics`; menu "Analytics"
* **Who:** anyone signed in to the admin app ([Access](https://docs.snapfix.com/how-the-apps-work/screens/staff.md#access)). The task positions come from a call that checks no membership, so any signed-in user can read the task names and positions of any group.
* **Feature:** [Usage dashboards](https://docs.snapfix.com/product/features/staff/usage-dashboards.md)

## Layout

1. **Title row.** "Analytics" on the left; on the right, the [account picker](https://docs.snapfix.com/how-the-apps-work/screens/staff.md#account-picker) for one site, placeholder "Type to search account". When the page opens, the first site in the list is selected and its pins load.
2. **Map.** A Google map under a spinner. It opens on a point in Ireland at zoom 3 and, once the pins arrive, fits them all.
   * One pin per task that has a latitude and a longitude, from the site's live task groups; asset registers and deleted groups are skipped.
   * The pin image follows the task's `color`: `green`, `red` and `yellow` each have an image, `amber` uses the yellow one, and any other value has no pin image.
   * Pins that are close together form clusters.
3. **Outside resources.** The page loads the Google Maps script with the key written into the app's code, the marker clustering script from a public CDN with no version pinned, and the cluster icons from Google's developer site. The map shows only once both scripts have loaded.

## Inputs

| Field   | Type                      | Required | Default                                                  | Rules and messages                                                                                              |
| ------- | ------------------------- | -------- | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Account | Single select with search | No       | The first site in the list, selected when the page opens | Picking another site reloads the pins. Clearing the field reloads the site list and keeps the last site's pins. |

## Actions

| Action        | Who              | What happens                                                                                                                                                                                                                                    | API                                                                                                                                                                                                                                                                 |
| ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Open the page | Anyone signed in | Loads the site list, selects the first site and loads its pins.                                                                                                                                                                                 | [`GET /v4/parents`](https://docs.snapfix.com/engineering-reference/api/staff.md#get-v4parents)                                                                                                                                                                      |
| Search sites  | Anyone signed in | Searches the site list by name; more sites load when the list is scrolled ([account picker](https://docs.snapfix.com/how-the-apps-work/screens/staff.md#account-picker)).                                                                       | [`GET /v4/parents`](https://docs.snapfix.com/engineering-reference/api/staff.md#get-v4parents)                                                                                                                                                                      |
| Pick a site   | Anyone signed in | Clears the pins and resets the view, loads the site's groups, then the positions of the tasks in its live task groups, and fits the map to the pins. If an earlier site's positions arrive after a new pick, its pins join the new site's pins. | [`POST ?action=admin_read_pri_business`](https://docs.snapfix.com/engineering-reference/api/staff.md#post-actionadmin_read_pri_business), then [`POST ?action=job_geo_stats`](https://docs.snapfix.com/engineering-reference/api/staff.md#post-actionjob_geo_stats) |
| Click a pin   | Anyone signed in | Opens the [info window](#info-window) for that task.                                                                                                                                                                                            | None                                                                                                                                                                                                                                                                |
| Pan or zoom   | Anyone signed in | Uses the map's own controls.                                                                                                                                                                                                                    | None                                                                                                                                                                                                                                                                |

## States

* **Loading:** the spinner covers the map from the start, and again on each pick, until the positions request ends.
* **Empty:** a site with no task groups, or no task with a position, shows no pins.
* **Error:** no message. A failed group list or positions request stops the spinner; the pins were cleared at the pick, so the map shows none.
* **Script failure:** when the Maps script or the clustering script does not load, the map area stays empty, with no message.
* **No permission:** none in the app.

## Dialogs and sheets

### Info window

Opens when a pin is clicked. It shows, in this order, "UUID", "Name" (the task), "Color", "Lat", "Lng", "Account Name" (the site), "Group Name" and "Deleted", with that task's values. It has no actions.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/how-the-apps-work/screens/staff/analytics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
