# Analyze VisitReport events

Count completed reports, track activity by day, or see which products visitors selected. Use these aggregates for an event dashboard. To read an individual participant’s details or free-text answers, use [Reports and participants](/visitreport/reports/).

## Get event totals

Find the [event ID](/visitreport/events/) and use a [personal API token](/authentication/) for an account with dashboard access to the event. The Analytics service calls the event ID `questionnaireId`. See the [API reference](/reference/visitreport-analytics/) for the full request schema.

```bash
ANALYTICS="https://backend.snapaddy.com/analytics/questionnaire/$EVENT_ID"

curl --fail-with-body "$ANALYTICS/reports/stats" \
  -H "x-api-key: $SNAPADDY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"completionStatus":"completed","timezone":"Europe/Berlin"}'
```

```typescript
const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");
const eventId = process.env.EVENT_ID;
if (!eventId) throw new Error("Set EVENT_ID");

const payload = {
  completionStatus: "completed",
  timezone: "Europe/Berlin"
};
const response = await fetch(`https://backend.snapaddy.com/analytics/questionnaire/${encodeURIComponent(eventId)}/reports/stats`, {
  method: "POST",
  headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
console.log(await response.json());
```

```python
import json
import os
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = {
    "completionStatus": "completed",
    "timezone": "Europe/Berlin"
}
request = Request(
    f"https://backend.snapaddy.com/analytics/questionnaire/{quote(os.environ['EVENT_ID'], safe='')}/reports/stats",
    method="POST",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"], "Content-Type": "application/json"},
    data=json.dumps(payload).encode(),
)
with urlopen(request, timeout=20) as response:
    print(json.load(response))
```

The response contains `numberOfReports`, `numberOfContacts`, `numberOfDays` with captured reports, and `numberOfUsers` who captured reports. One report can represent more than one contact. The default status is `completed`. Use `all` to include in-progress reports or `in-progress` to count them separately.

## Build a breakdown

Call `GET /reports/time-range` under the same event URL to find when the oldest and newest reports were captured. Then choose an aggregate for your chart.

| Question | Path under the event URL |
| --- | --- |
| When were reports captured? | `POST /reports/count-by-day` or `POST /reports/count-by-hour` |
| Who captured reports? | `POST /reports/count-by-user` |
| Where did contacts come from? | `POST /reports/contacts/count-by-country` or `POST /reports/contacts/count-by-source` |
| When were contacts captured? | `POST /reports/contacts/count-by-day` |

See the [API reference](/reference/visitreport-analytics/) for the full request schema.

```bash
ANALYTICS="https://backend.snapaddy.com/analytics/questionnaire/$EVENT_ID"

curl --fail-with-body "$ANALYTICS/reports/count-by-day" \
  -H "x-api-key: $SNAPADDY_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"timezone":"Europe/Berlin"}'
```

```typescript
const apiKey = process.env.SNAPADDY_API_KEY;
if (!apiKey) throw new Error("Set SNAPADDY_API_KEY");
const eventId = process.env.EVENT_ID;
if (!eventId) throw new Error("Set EVENT_ID");

const payload = {
  timezone: "Europe/Berlin"
};
const response = await fetch(`https://backend.snapaddy.com/analytics/questionnaire/${encodeURIComponent(eventId)}/reports/count-by-day`, {
  method: "POST",
  headers: { "x-api-key": apiKey, "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`Request failed (${response.status})`);
console.log(await response.json());
```

```python
import json
import os
from urllib.parse import quote
from urllib.request import Request, urlopen

payload = {
    "timezone": "Europe/Berlin"
}
request = Request(
    f"https://backend.snapaddy.com/analytics/questionnaire/{quote(os.environ['EVENT_ID'], safe='')}/reports/count-by-day",
    method="POST",
    headers={"x-api-key": os.environ["SNAPADDY_API_KEY"], "Content-Type": "application/json"},
    data=json.dumps(payload).encode(),
)
with urlopen(request, timeout=20) as response:
    print(json.load(response))
```

The daily report breakdown counts completed reports and returns an array of `name` and `value` pairs. The date in `name` uses `YYYY-MM-DD`. Use the same explicit time zone across charts so report timestamps are grouped consistently. The aggregate request schemas also describe `staticFilters` and `questionFilters` to narrow the data.

## Count selected answers

Find the group and question IDs in the event's [questionnaire structure](/reference/visitreport-questionnaire/). Under the event URL, use `GET /group/{questionGroupId}/question/{questionId}/options` to read the choices, then `POST /group/{questionGroupId}/question/{questionId}/answer-counts` with the same time zone and filters you use for your report breakdown. A multi-select question can count several selected options from one report.

[Event Analytics API reference](/reference/visitreport-analytics/)
