Collect visitor screen size

Last updated:

You can record the screen size of the devices that visitors use in your web application, for example to decide which screen resolutions to support. Screen size isn't one of the fields that Pendo collects by default, so you send it from your application as visitor metadata or as a Track Event property. If your subscription includes Session Replay, each replay also shows the size of the browser window it was recorded in.

Choose the method that matches what you want to see:

  • Visitor metadata. One value per visitor, updated each time they load your app. Use it to count visitors by screen size, build segments, and group Data Explorer reports. Pendo keeps the most recent value unless you turn on historical metadata for the field.
  • Track Event property. One value each time the event is sent. Use it to see every size a visitor used and how often each size appears, on the Track Event's details page or in Data Explorer.
  • Session Replay. The browser window size of one recorded session, shown in the replay player. Use it when you're reviewing one visitor's session and want to know the window size they had.

Before you begin

Sending screen size as metadata or as a Track Event requires a change to your application's code, so you need help from a developer. The examples in this article use the browser values window.screen.width and window.screen.height, which report the resolution of the visitor's screen. To record the size of the browser window instead, use window.innerWidth and window.innerHeight.

Combine the width and height into one text value, such as 1920x1080. Pendo can group reports by text values, so one combined value gives you one row for each screen size.

Send screen size as visitor metadata

Add the screen size to the visitor object in your install script. Pendo creates the metadata field the first time it receives the value and updates it each time the visitor loads your app, so each visitor's record holds the size they used most recently.

  1. In your install script, add a field to the visitor object. For example:
    visitor: {
      id: "VISITOR-UNIQUE-ID",
      screen_size: window.screen.width + "x" + window.screen.height
    }
  2. After visitors load your app, go to Settings > Metadata and confirm that the field appears in the Visitor-level data tab with the Text data type. If your subscription blocks undefined web SDK metadata fields, add the field there first. For more information, see Block undefined web SDK metadata fields.
  3. To keep every value a visitor sends instead of the most recent one, turn on historical metadata for the field. For more information, see Historical metadata.

The field appears on each visitor's details page and in the segment builder. To count visitors by screen size, build a Data Explorer report, select Any activity, set the measurement to Number of unique visitors, and group by the field under Visitor metadata. For more information, see Configure visitor and account metadata and Build a Data Explorer report.

Send screen size with a Track Event

Send a Track Event with the screen size as an event property when your app loads, or at another point in your app that you choose. Pendo records the value with every event, so you can see all the sizes each visitor used and how often each size appears.

  1. In your application, send a Track Event with the screen size as a property. For example:
    pendo.track("Screen size", {
      screen_size: window.screen.width + "x" + window.screen.height
    });
    You can also send the Track Event from a code block in a guide to record the size when the guide displays. For more information, see Configure Track Events.
  2. Go to Settings > Event properties and confirm that the property's Type is string. You need to be a subscription admin or have the Manage event properties permission to open this page. Track Event properties are collected as strings by default, and string values can be grouped in Data Explorer.
  3. Go to Product > Track Events and select the event. The Event breakdown table at the bottom of the details page lists each screen size that visitors sent. Remove the Visitor column to see a Total Events count for each screen size.

To analyze the sizes over time, build a Data Explorer report with the Track Event and group by the property under Event properties. For more information, see Build a Data Explorer report.

View the window size in a replay

Session Replay is a paid add-on to Pendo. If it's included in your subscription, the replay player shows the width and height of the visitor's browser window, in pixels, below the video for web applications. This is the size at the start of the recording and applies to that replay only. For more information, see Watch replays.

Was this article helpful?
0 out of 0 found this helpful