Frontend

Analytics

Count visitors, pageviews, and custom events, and see where visits convert, without cookies

Analytics counts the visitors, pageviews, and custom events of your website or web app. It shows where visitors come from, which pages they open, and where they leave a funnel. The data comes from the browser SDK, so it sits in the same project as your traces and errors.

Analytics sets no cookies, uses no browser storage, and never receives the identity of your users.

Analytics overview over 30 days, with estimated visitors, visits, pageviews, events, visit duration, and bounce rate, followed by pages, sources, browsers, and events

Setup

Add analytics() to the integrations of the browser SDK:

src/monocle.ts
import { analytics, errors, initMonocle, network } from '@monocle.sh/browser-sdk'

export const monocle = initMonocle({
  dsn,
  environment: 'production',
  integrations: [network(), errors(), analytics()],
})

The SDK records a pageview for the first page and for each path change, including in single-page apps. To record a custom event, call monocle.track():

TypeScript
monocle.track({ name: 'plan_selected', properties: { plan: 'pro' } })

The browser SDK page lists the event rules, the router options, and how to hide sensitive paths.

How Monocle counts visitors

Monocle can't recognize a returning visitor, by design. The visitor ID is a hash of the site, the IP address, and the User-Agent, with a secret that changes every day at midnight UTC. Monocle uses the IP address and the User-Agent in memory, then drops them.

MetricDefinition
Estimated visitorsUnique visitors of each day, added over the range. A person who comes back on another day counts again.
VisitsActivity of one visitor. A visit ends after 30 minutes without activity, and at midnight UTC.
PageviewsPages viewed.
EventsCustom events sent with track().
Visit durationAverage time of a visit. Each page counts the time it was visible.
Bounce rateShare of visits with a single pageview.

Monocle drops bots, headless browsers, monitoring tools, and scripts before counting. Their errors, traces, and logs stay in Monocle.

Overview

The Overview shows these metrics for the selected range, with a chart. Turn on Previous period to compare each metric with the period just before.

Below the chart, cards list the top pages, sources and UTM campaigns, browsers and devices, custom events, and locations. Click a row to filter the whole page on it. Locations come from the IP address and stop at the city.

AI assistant referrals counts the visits that come from AI assistants such as ChatGPT, Perplexity, Claude, Gemini, and Copilot. Monocle recognizes an assistant by the referrer of the visit. A link opened without a referrer counts as the assistant when its utm_source names one, such as utm_source=chatgpt.com, and as direct otherwise. Click an assistant to filter the overview on it, or click Filter AI visits to keep the visits of every assistant.

Filter on one event to see its Properties card and its conversion rate.

Annotations

Annotations are short notes on the chart, such as Landing page redesign. Use them to explain a change in traffic later.

To add one, click the chart at the moment it happened, write the note, then press Enter. Point at a note to edit or delete it. Everyone with access to the environment sees the same annotations. AI agents can also manage them through the MCP server.

Filters

Click Add filter to narrow every card and chart. You can filter on pages and routes, sources and UTM values, location, browser and device, events, and event properties. Filters combine with AND and stay in the URL, so you can share the view.

Source, UTM, entry, exit, and event filters keep whole visits. For example, Event is purchase keeps every page and event of the visits that sent purchase.

Pages

Pages lists every page with its pageviews, visitors, bounce rate, and average duration. Pages are grouped by route, such as /blog/:slug. Expand a route to see its URLs. To use the routes of your router, pass route to analytics().

Each page also shows its JavaScript error rate. Errors come from the errors() integration. They have no visitor attached, so they follow the site, service, and date range, but not the other filters.

Web Vitals

Web Vitals shows how fast your pages load and react for real visitors, with the three Core Web Vitals:

MetricMeasuresGoodPoor
LCPTime until the main content showsUp to 2.5sOver 4s
INPTime the page takes to react to an interactionUp to 200msOver 500ms
CLSHow much the content moves while it loadsUp to 0.1Over 0.25

Pick a metric to see its trend over the range and the share of good measurements. Switch between the 50th, 75th, 90th, and 95th percentiles. The table ranks routes or URLs by any metric. Click a row to scope the chart to that page.

analytics() measures Web Vitals from version 0.14.0 of the browser SDK. To turn them off, pass webVitals: false. Web Vitals have no visitor attached, so they follow the site, service, and date range, but not the other filters.

Sessions

Sessions lists the visits of the range with their source, entry and exit pages, duration, and device. Click a visit to see its journey: every page and event in order.

A visit stays anonymous. It has no link to your users or to the other visits of the same person.

Funnels

A four-step funnel from a product page to a purchase, with the share of visits at each step and the conversion by source

A funnel shows how many visits go through a series of steps, and where the others stop.

  1. Open Funnels under Analytics.
  2. Click Add step and pick a page URL, a route, or a custom event.
  3. Add 2 to 8 steps.
  4. To keep the funnel, click Save funnel.

The steps must happen in order, within one visit. For each step, the funnel shows the visits that reached it and the median time from the previous step. Click dropped off to see the visits that stopped there. Conversion by splits the results by source, entry page, country, or device.

Retention

Analytics keeps your data for the same periods on every plan:

DataKept forUsed by
Daily totals25 monthsOverview, Pages, and Events without filters
Detailed data365 daysFilters, Sessions, Funnels, and event properties
Web Vitals90 daysWeb Vitals, and the errors of Pages

Pick 90d, 12mo, or a custom range up to 25 months back. Filtered reports go back 365 days.

On busy sites, a long filtered range can read a share of the visitors and scale the counts up. The report then shows Estimated from X% of visitors under the chart.

Analytics doesn't count toward your telemetry GB. See Analytics billing for the included events and the price of extra events.

Limits

  • Analytics doesn't follow the Do Not Track setting. To skip those visitors, leave analytics() out when navigator.doNotTrack is '1'.
  • On a site with tens of millions of events a year, a filter over several months can time out. Shorten the range.

Search documentation

Search pages and sections of the Monocle documentation