Skip to content

The complete guide to analytics for Babylon.js apps

Analytics for a Babylon.js app means measuring what happens inside the canvas: where visitors look, which meshes they pick, where they move, what they never notice, and how smoothly the scene runs on their devices. Page analytics can’t do this, because everything Babylon.js draws ends up in a single <canvas> element. This guide covers what’s worth measuring, how to capture it with @uptimizr/babylon, and how to read the results.

Uptimizr is open source (Apache-2.0) and self-hosted. The examples below send data to a collector you run yourself, and nothing goes to a third party.

Question Signal Captured
Which meshes do people click? Picks on named meshes By default
What do they click that does nothing? Clicks that hit no geometry, and rapid repeat clicks By default
Which way do they look? Camera direction, binned on a sphere By default
What do they actually look at? The camera-forward ray hitting geometry (gaze) Opt-in: capture.gaze
Where do they stand and walk? Camera positions on the ground plane By default
What do they hover but never click? Hover dwell on meshes Opt-in: hoverDwell
What’s on screen but ignored? On-screen time against engagement, per mesh Opt-in: meshVisibility
Does it run smoothly on their device? FPS, p95/p99 frame time and long frames By default
Where in the scene does FPS drop? Each FPS sample tagged with the camera position By default
Do shaders stall the first interaction? Shader and pipeline compile time By default
What happened in one particular session? The ordered event stream, replayed in your scene Readable on opt-in
Did they reach the goal? Your own events, such as add_to_cart When you call track()

The last four rows go further on Babylon.js than on other engines. Frame-time percentiles, long frames, compile stalls and the position on each FPS sample come from Babylon’s own engine hooks, so the jank and scene-health reports have the most to work with here.

1. Run a collector. The scaffolder creates a self-hosted collector with an embedded DuckDB file and the dashboard:

Terminal window
npm create uptimizr@latest

See Run the collector for Docker, Postgres and other options.

2. Install the connector. @babylonjs/core is a peer dependency, so the connector uses your copy and never bundles its own:

Terminal window
npm install @uptimizr/babylon @babylonjs/core

3. Call trackScene once your scene exists:

import { trackScene } from "@uptimizr/babylon";
const tracker = trackScene(scene, {
projectId: "my-babylon-app",
endpoint: "https://collect.example.com",
});

Open the dashboard and move around your scene. Heatmaps, the mesh ranking and performance charts fill in as events arrive. Prefer a script tag, or working in the Babylon.js Playground? See the CDN bundle and playgrounds pages.

Mesh analytics reports the name of the mesh a pick hit. Models exported from Blender or another tool often arrive with names like Cube.012, so give every mesh you care about a deliberate, stable name once the model has loaded:

scene.getMeshByName("Cube.012")!.name = "chair-seat";
scene.getMeshByName("Cylinder.003")!.name = "chair-legs";

Clone suffixes split one object across several rows, and an unnamed mesh reports an empty name. To draw heatmaps against a recognizable backdrop without uploading your geometry, register a scene proxy of per-mesh bounding boxes.

By default the connector follows scene.activeCamera. With picture-in-picture, split-screen or render-target rigs, “active” is ambiguous, so pass the camera people actually see through:

trackScene(scene, { projectId, endpoint, camera: mainCamera });

Gaze, hover and visibility capture are off by default, for privacy and cost. Turn on the ones you need:

const tracker = trackScene(scene, {
projectId: "my-babylon-app",
endpoint: "https://collect.example.com",
capture: { gaze: true, hoverDwell: true, meshVisibility: true },
gaze: { predicate: (mesh) => mesh.name !== "ground" },
});

Gaze adds one scene.pickWithRay() per camera sample that’s actually sent, not one per frame. It never adds a timer, and a still camera costs nothing. It’s a head-direction proxy, not eye tracking. Hover dwell runs its own bounded pick, so your meshes don’t need enablePointerMoveEvents or an action manager. See Performance & diagnostics → gaze.

Discrete moments that matter to your product are custom events. Areas, levels and views are scenes:

tracker.track("add_to_cart", { sku: "CHAIR-01", finish: "walnut" });
tracker.setScene("showroom"); // later heatmaps and rankings can be filtered to this scene

Custom events can feed a per-session funnel, and every report accepts a scene filter. See Custom events & input for keyboard actions, GUI buttons and capability changes.

  • WebGPU. trackScene works the same on a WebGPUEngine as on the WebGL Engine. The session records webgpu as its graphics API and wgsl as its shading language, so you can compare WebGPU and WebGL2 sessions side by side. With graphics diagnostics turned on, the connector also reports WebGPU device loss and validation errors. See Analytics for WebGPU apps.
  • First-person scenes. When the canvas holds pointer lock (engine.enterPointerlock()), the connector reports clicks from the crosshair at the centre of the screen. Read the gaze and floor-plan heatmaps for these scenes, because the screen-space pointer heatmap will cluster in the middle.
  • WebXR. XR capture is opt-in: pass the experience from createDefaultXRExperienceAsync() as xr: { experience }. Controller and gaze rays become pointer events, and the trigger becomes a click. See Babylon.js → WebXR, including AR placement.

The dashboard covers the common questions. Every view is also a query API endpoint you can call:

You want Endpoint
The most-clicked meshes GET /api/v1/meshes/top
Clicks that hit nothing, and rage clicks GET /api/v1/clicks/dead, GET /api/v1/clicks/rage
Where people clicked, in 3D GET /api/v1/heatmaps/world
Which way they looked GET /api/v1/heatmaps/camera
Seen but ignored meshes GET /api/v1/meshes/blind-spots
FPS percentiles and FPS by device GET /api/v1/perf/distribution, GET /api/v1/perf/by-device
Frame-time tail and long frames GET /api/v1/perf/frame-time, GET /api/v1/perf/jank
Where in the scene FPS drops GET /api/v1/heatmaps/perf
Which scene to fix first GET /api/v1/insights/scene-health
GET /api/v1/meshes/top?since=2026-11-01&limit=20&format=summary
x-api-key: your-project-api-key

You can also paint the heatmaps straight into your running Babylon.js scene with @uptimizr/heatmap/babylon, or ask an AI agent questions such as “which meshes do people look at but never click?” against the same data.

Replay re-drives a recorded session in your real Babylon.js scene, not in a video. It moves your camera and gives you callbacks for each pointer and mesh event:

import { fetchSessionEvents, ReplayPlayer } from "@uptimizr/replay";
import { createBabylonReplayDriver } from "@uptimizr/replay/babylon";
const events = await fetchSessionEvents({ endpoint, apiKey, sessionId });
const driver = createBabylonReplayDriver({
scene,
onPointer: (screen, hitPoint, hitMesh) => {
/* draw a cursor or flash the mesh */
},
onMeshInteraction: (mesh, kind) => {
/* highlight the mesh */
},
});
new ReplayPlayer(events, driver, { speed: 1 }).play();

Reading a session’s events needs ENABLE_RAW_SESSION_RETENTION=true on the collector and an API key with the query:raw capability. See Session replay and Session replay for WebGL for how this compares with canvas video recording.

The default setup writes no cookies and stores no persistent identifier in the browser. The session id lives in memory, and visitors are counted with a hash that the server computes and rotates daily. Gaze, hover and visibility capture are off until you turn them on. See Privacy & configuration. Whether you need a consent banner still depends on your jurisdiction and what you capture.

Does this work with Babylon Lite? Yes, through a separate connector, @uptimizr/babylon-lite. Babylon Lite is WebGPU-only and has no scene observables, so you pass the scene, camera and canvas explicitly. See Babylon Lite analytics.

Does it change my scene? No. The connector reads your scene, camera and engine, and never mutates them. Babylon.js stays a peer dependency, so the connector never ships a second copy.

Do I need a server? Yes, a collector, which you run yourself. It’s a single Node process with an embedded database. To try the reports first, open the live demo, which runs entirely in your browser.

Can I use it alongside Google Analytics, PostHog or Mixpanel? Yes. Keep those for pages, acquisition and conversions, and use Uptimizr for what happens in the canvas. See Why Google Analytics can’t see inside a 3D scene.

What does it cost? Uptimizr is free and open source. You pay for wherever you host the collector.