Metrics_
How Appwrite Analytics calculates visitors, visits, pageviews, bounce rate, visit duration, and engagement time, which breakdowns it offers, and how to read metrics from your own code.
6 min read
Every figure on an analytics dashboard comes from the events your property receives. This page defines each metric and breakdown, and shows how to read the same numbers from your own code.
Dashboard metrics
The row of metrics at the top of the dashboard covers the selected date range.
- Unique visitors: distinct visitors in the range. Someone who returns several times counts once.
- Visits: visits that started in the range. A visit that started earlier doesn't count, even if it continued into the range.
- Pageviews:
pageviewandscreen_viewevents, including repeat views of the same page or screen. - Views per visit: pageviews divided by visits.
- Bounce rate: the share of visits with fewer than two pageviews.
- Visit duration: the average time from a visit's first event to its last. A visit with a single event counts as 0 seconds.
- Engagement time: the average active time per visit, counting only visits that reported any. On the web, a page is active while it's visible. In a Flutter app, the app is active while it's in the foreground.
Bounce rate and Visit duration cover the same visits as Visits: the ones that started in the range. The Visits chart is different: each point counts the visits with an event in that hour or day, so a visit that crosses midnight appears on both days, and the points can add up to more than the total.
With a Page or Event filter, the dashboard can't calculate totals for the whole range, so Unique visitors and Visits add up the chart's points. A visitor who returns on several days then counts once for each day, or once for each hour with 1h.
Exports and the API also include Scroll depth, the average of the deepest scroll positions that pages reported, from 0 to 100 percent. The Web helper reports a page's scroll depth only if the visitor scrolled it.
These metrics include bot traffic. The Humans vs bots card shows how much of it comes from bots. For how Appwrite identifies visitors and splits their events into visits, see Visitors and sessions.
Breakdowns
The cards below the chart break traffic down by one dimension at a time and rank the values by visitors. The Custom events card is the exception: it ranks events by how many times they were sent. The API uses the same dimensions, by the names in this table, and ranks by visitors, except for eventName, which it ranks by event count. Unlike the card, eventName also includes the automatic events.
| Dimension | Dashboard card | Values |
|---|---|---|
channel | Traffic sources | direct, search, ai, social, email, paid, or referral |
referrerSource | Traffic sources | The referring hostname, such as google.com |
utmSource, utmMedium, utmCampaign, utmContent, utmTerm | Traffic sources | UTM parameters from the URL a visitor landed on |
page | Pages | The page path, such as /pricing |
entryPage, exitPage | Pages | The first and last page of each visit |
hostname | Pages | The hostname of the page |
country | Locations | Two-letter country code, such as US. The dashboard shows country names. |
region, city | Locations | Region and city names, such as California |
browser | Technology | Such as Chrome, Mobile Safari, or Firefox |
operatingSystem | Technology | Such as Windows, iOS, Mac, or Android |
device | Technology | Such as desktop, smartphone, or tablet |
screenSize | Technology | mobile, tablet, laptop, or desktop |
trafficType | Humans vs bots | human or bot |
botCategory, botName | Humans vs bots, AI agents and crawlers | Such as ai crawler and GPTBot |
eventName | Custom events | The event name |
Each row has the number of visitors, visits, and events with that value. In the API, visits are the sessions field. On Entry pages and Exit pages, they're the visits that started in the range. On every other breakdown, they're the visits with an event in the range. For how sources and channels are worked out, see Traffic sources. For bot categories, see Bots and AI traffic.
Screen sizes come from the viewport width: mobile below 576 pixels, tablet from 576 to 991, laptop from 992 to 1439, and desktop from 1440 up.
Read metrics from your code
Read metrics with listMetrics and an API key that has the analytics.read scope. To create one, follow the steps in Track events from your server and select analytics.read instead.
This example lists the five countries with the most visitors over the last seven days.
import { Client, Analytics, AnalyticsDimension } from 'node-appwrite';
const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') .setProject('<PROJECT_ID>') .setKey('<API_KEY>');
const analytics = new Analytics(client);
const countries = await analytics.listMetrics({ propertyId: '<PROPERTY_ID>', dimensions: [AnalyticsDimension.Country], dateRange: '7d', limit: 5,});
for (const row of countries.metrics) { console.log(row.value, row.visitors);}Response shapes
listMetrics returns one of three shapes, depending on whether you pass dimensions or interval. You can't pass both.
| You pass | You get | Fields |
|---|---|---|
| Neither | One row with totals for the whole range | Every metric on this page |
dimensions | One row per value, ranked by visitors (eventName by events), with value set | visitors, sessions, and events |
interval | One row per time bucket, oldest first, with date set | visitors, sessions, pageviews, and events |
Without dimensions or interval, the single row looks like this:
{ "total": 1, "metrics": [ { "value": null, "date": null, "visitors": 14212, "sessions": 22603, "pageviews": 63207, "events": 144886, "visits": 22601, "bounceRate": 46.9, "visitDuration": 77.01, "viewsPerVisit": 2.79, "scrollDepth": 61.3, "engagementTime": 75 } ]}visitDuration and engagementTime are in seconds. bounceRate and scrollDepth are percentages.
sessions and visits count visits in two ways. sessions counts every visit with an event in the range. visits counts only the visits that started in it, like Visits on the dashboard. They differ when a visit started before the range.
Parameters
| Parameter | Description |
|---|---|
dimensions | One dimension to break down by, from the breakdowns table. |
interval | The bucket size for a time series: 1h, 1d, 1w, or 1m. Buckets start in UTC. |
dateRange | The length of the range in days, such as 7d. Defaults to 30d. Any other format, such as 2w, also falls back to 30d. |
startAt, endAt | Exact bounds in ISO 8601. Times without an offset are UTC. With both, they override dateRange. With only startAt, the range ends now. With only endAt, the range is dateRange long and ends at endAt. |
queries | Up to 10 filters. See Filter metrics. |
limit | The number of rows a breakdown returns, from 1 to 500. Defaults to 100. |
A range never starts before your plan's data retention.
Filter metrics
Filters narrow the events every metric is calculated from. Each filter is a query on a dimension, using equal, notEqual, contains, startsWith, or endsWith. This example returns daily visitors who arrived from search engines over the last two weeks.
import { Client, Analytics, AnalyticsInterval, Query } from 'node-appwrite';
const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') .setProject('<PROJECT_ID>') .setKey('<API_KEY>');
const analytics = new Analytics(client);
const days = await analytics.listMetrics({ propertyId: '<PROPERTY_ID>', interval: AnalyticsInterval.OneDay, dateRange: '14d', queries: [Query.equal('channel', 'search')],});
for (const row of days.metrics) { console.log(row.date, row.visitors);}You can filter on every dimension except entryPage, exitPage, and trafficType. Filters on page and eventName work with interval, or with a breakdown on any dimension other than entryPage and exitPage. Totals don't accept them, because totals also cover whole visits.
Was this page helpful?
Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.