PageViewTiming: Async or dynamic page details

Browser monitoring's PageViewTiming event sends each data point as a separate event as soon as it is available. Because we do not restrict the timing, you can receive first paint or first interaction data regardless of when it fires. This document describes why and how to use PageViewTiming and its attributes to query data about your site, component loading, and user performance metrics, both from visual and responsiveness standpoints.

Why use PageViewTiming?

If your application uses asynchronous or dynamic pages, you may need additional details about site or component loading. But pages can load content in many different ways, and users control when they interact with that content. This is why some user-centric performance metrics happen outside the standard window onload (page load time) in the Browser agent.

For example, users may become impatient and begin clicking as soon as content is on the webpage. Or, they may wait to use the page until long after content is loaded.

The PageViewTiming event provides a more real-time delivery mechanism that does not have a dependency on any other event. The additional metrics can help you understand how users experience your site, both from visual and responsiveness standpoints.

Support for Google's Core Web Vitals

We now, with the release of agent version 1177, have full support for Google's Core Web Vitals for 2020. The metrics that make up Core Web Vitals will evolve over time. The current set for 2020 focuses on three aspects of the user experience—loading, interactivity, and visual stability—and includes the following metrics (and their respective thresholds):

A diagram showing the three components of the Core Web Vitals metrics.
Core Web Vitals metrics include loading, interactivity, and visual stability.
  • Largest Contentful Paint (LCP): measures loading performance. To provide a good user experience, LCP should occur within 2.5 seconds of when the page first starts loading.
  • First Input Delay (FID): measures interactivity. To provide a good user experience, pages should have a FID of less than 100 milliseconds.
  • Cumulative Layout Shift (CLS): measures visual stability. To provide a good user experience, pages should maintain a CLS of less than 0.1.

For each of the above metrics, to ensure you're hitting the recommended target for most of your users, a good threshold to measure is the 75th percentile of page loads, segmented across mobile and desktop devices.

Detailed visual, interactivity, and responsiveness metrics

The BrowserInteraction and PageView events end their reporting when they receive the page window load (or window load and AJAX) timing. However, paint and interactivity metrics can happen at any time. PageViewTiming delivers these metrics as a separate event to:

  • Account for the variability in this timing.
  • Avoid setting an arbitrary timeout.
  • Prevent holding BrowserInteraction and PageView events indefinitely.
Additional data Comments
firstPaint and firstContentfulPaint

The firstPaint and firstContentfulPaint attributes already are available with BrowserInteraction and PageView events. However, they are not always reliably captured before the window onload event fires.

Using PageViewTiming gives you a way to capture these metrics even if they happen after the original page load time. This gives you a better understanding of the correlation between responsiveness of that load event and the visual rendering of your content.

largestContentfulPaint

This new metric, available with agent version 1163, largestContentfulPaint, reports the render time of the largest content element visible in the viewport. Google's research found looking at when the largest element was rendered was a more accurate way to measure when the main content of a page is loaded and useful. Details on this metric, including limitations and considerations can be found in the w3c draft.

In addition, we now report the cumulative layout shift (CLS) score attribute with LCP. This attribute is reported as cumulativeLayoutShift.

Largest Contentful Paint is one of three metrics identified by Google as the Core Web Vitals. LCP values up to 2.5 secs are considered "Good", between 2.5-4.0 secs considered "Needs Improvement", and above 4.0 secs considered "Poor."

firstInteraction and firstInputDelay

With the addition of firstInteraction and firstInputDelay, you can quickly determine the ways that your users are interacting with that visual content. These metrics tell you not only when they interacted, but what type of interaction (mousedown, pointerdown, etc.) and how long it took for them to receive a response from your site.

The firstInputDelay metric lies in the middle of FirstContentfulPaint and Time to Interactive (TTI) metrics, measuring the time between when a first input can be made and when the browser's main thread is able to respond to any interactions.

In addition, we now report the cumulative layout shift (CLS) score attribute at the moment of the user's first interaction. This attribute is reported as cumulativeLayoutShift.

First Input Delay is one of three metrics identified by Google as the Core Web Vitals. FID values up to 100 ms are considered "Good", between 100-300 ms considered "Needs Improvement", and above 300 ms considered "Poor."

For a more detailed explanation, see the Browser release notes.

cumulativeLayoutShift

Cumulative Layout Shift (CLS), available with agent v1177, is an important, user-centric metric for measuring visual stability because it helps quantify how often users experience unexpected layout shifts—a low CLS helps ensure that the page is delightful. This is one of three metrics identified by Google as the Core Web Vitals.

Cumulative Layout Shift is one of three metrics identified by Google as the Core Web Vitals. CLS scores up to 0.1 are considered "Good", between 0.1-0.25 considered "Needs Improvement", and above 0.25 considered "Poor."

timingName

You can review different types of activities with the timingName attribute, such as firstPaint, firstContentfulPaint, firstInteraction, largestContentfulPaint, pageHide and windowUnload. For example, a PageViewTiming event may have a timingName of firstPaint and a firstPaint value of .03. The event will also include all default attributes included with the standard BrowserInteraction and PageView events.

elementId This is the Id, if specified, of the largestContentfulPaint element. This value will only be reported with the LCP metric. This value can be null.
elementSize This is the reported size of the largestContentfulPaint element. This value will only be reported with the LCP metric.
pageHide

The pageHide event, available with agent v1177, is sent when the browser hides the current page in the process of presenting a different page from the session's history. For example, when the user clicks the browser's Back button, the current page receives a pageHide event before the previous page is shown. Supporting documentation and browser compatibility for the pageHide event can be found in MDN docs.

In addition, we now report the cumulative layout shift (CLS) score attribute with pageHide. This attribute is reported as cumulativeLayoutShift.

windowLoad

The windowLoad event, available with agent v1177, is fired when the whole page has loaded, including all dependent resources such as stylesheets and images. Supporting documentation and browser compatibility for the Window Load event can be found in MDN docs.

In addition, we now report the cumulative layout shift (CLS) score attribute with windowLoad. This attribute is reported as cumulativeLayoutShift.

windowUnload

The windowUnload event, available with agent v1163, is fired when a document or child resource is being unloaded. Supporting documentation and browser compatibility for the Window Unload event can be found in MDN docs.

In addition, we now report the cumulative layout shift (CLS) score attribute with windowUnload. This attribute is reported as cumulativeLayoutShift.

Compatibility and requirements

In addition to Browser's installation requirements, the PageViewTiming event requires Browser agent version 1153 or higher and a Browser Pro subscription. Follow our Browser agent release notes to find out when new metrics are released.

These metrics are supported by the following browser versions. For unsupported browsers, no PageViewTiming events will be recorded.

Metrics Supported browser versions
cumulativeLayoutShift

firstPaint

firstContentfulPaint

  • Chrome 60 or higher for desktop and mobile (Android webview and Chrome for Android)
  • Opera 47 or higher for desktop
  • Opera 44 or higher for Android mobile
  • Samsung Internet for mobile
largestContentfulPaint
  • Chrome 77 or higher for desktop and mobile

firstInteraction

firstInputDelay

These metrics require the addEventListener Browser API. This API is available in all modern browsers, including:

  • Apple Safari
  • Google Chrome
  • Microsoft Internet Explorer (IE) versions 9 or higher
  • Mozilla Firefox
pageHide This metric is currently supported by all browsers on desktop and mobile. Compatibility matrix via MDN documentation.
windowLoad This metric is currently supported by all browsers on desktop and mobile. Compatibility matrix via MDN documentation.
windowUnload This metric is currently supported by all browsers on desktop and mobile. Compatibility matrix via MDN documentation.

Query your event data

Here are some sample queries for the event data to help you get started.

Percentile over timeseries

Show the 95th percentile of first paint and first contentful paint over a time series:

SELECT FILTER(percentile(firstPaint, 95), where(timingName = 'firstPaint')) as 'fp', FILTER(percentile(firstContentfulPaint, 95), where(timingName = 'firstContentfulPaint')) as 'fcp' FROM PageViewTiming TIMESERIES 1 minute SINCE 1 hour ago
Percentile by transaction and interaction

Show the 95th percentile of first input delay over a time series, faceted by transaction name and interaction type:

SELECT percentile(firstInputDelay, 95) as 'fid' FROM PageViewTiming WHERE timingName = 'firstInteraction' TIMESERIES 1 minute FACET browserTransactionName, interactionType SINCE 3 hours ago
Histogram of delay timings

Show a histogram of first input delay timings faceted by first interaction time ranges:

FROM PageViewTiming SELECT histogram(firstInputDelay, 1000, 10) SINCE 3 hours ago WHERE timingName = 'firstInteraction' FACET CASES (WHERE firstInteraction < 1, WHERE firstInteraction >= 1 AND firstInteraction < 5, WHERE firstInteraction >= 5)

For more help

If you need more help, check out these support and learning resources: