Time on Page

Automatic tracking of active time spent on each page.

How It Works

Palace Tracker measures active time only — the timer pauses automatically when the tab becomes hidden (e.g. the user switches tabs or minimises the window) and resumes when they return. This gives a more accurate picture of genuine engagement than a simple page load to unload duration.

For SPAs, the timer resets on every route change, so each virtual page view is measured independently.

When Data Is Sent

The page_exit event is fired when:

  • The page is hidden or closed (pagehide event)
  • The tab visibility changes to hidden (visibilitychange event)
  • The user navigates to a new route in an SPA

The tracker uses sendBeacon to ensure the event is delivered reliably even as the page is unloading. If a page is restored from the browser's back/forward cache, the timer resets and tracking starts fresh.

Data Format

Time on page is included in the page_exit event alongside scroll depth:

{
  "eventType": "page_exit",
  "data": {
    "duration": 45,
    "maxScrollDepth": 87
  }
}

duration is the total active time in seconds, rounded to the nearest second.