User scrolled
Learn how to track when a user scrolls the content.
This event tracks when a user scrolls the content. Here, "scroll" is a general term that covers any scrolling interaction, whether it's a mouse wheel, a swipe on a touchscreen, or a keyboard shortcut.
The SDK automatically tracks this event when a user scrolls the content.
Input properties
This event has no input properties.
Processed properties
These properties are automatically tracked:
- start(optional)object
The scroll offset at the beginning of the gesture, in pixels.
This is the distance from the top-left corner of the surface to the top-left corner of the viewport. For example, if the user has scrolled 500 pixels down, y is 500.
Maximum scroll valueEven when the user scrolls to the very bottom, y does not equal the surface height. That is because y tracks the top edge of the viewport, not the bottom edge. The maximum value of y is surfaceSize.height - viewportSize.height.
- endobject
The scroll offset at the end of the gesture, in pixels.
This is the distance from the top-left corner of the surface to the top-left corner of the viewport. For example, if the user scrolled to 780 pixels down, y is 780.
Maximum scroll valueEven when the user scrolls to the very bottom, y does not equal the surface height. That is because y tracks the top edge of the viewport, not the bottom edge. The maximum value of y is surfaceSize.height - viewportSize.height.
- surfaceSize(optional)object
The total dimensions of the scrollable surface, in pixels.
This represents the entire scrollable area, not just the visible portion. For example, on a web page, this would be the full document size, including content below the fold. In a mobile app, it would be the entire scrollable screen area.
- viewportSize(optional)object
The dimensions of the visible area, in pixels.
This is the portion of the surface currently visible to the user. For example, on the web, this would be the browser window size. In a mobile app, it would be the device screen size.
Payload examples
Below are some payload examples for this event:
{ "type": "userScrolled", "start": { "x": 0, "y": 150 }, "end": { "x": 0, "y": 780 }, "surfaceSize": { "width": 1920, "height": 5400 }, "viewportSize": { "width": 1920, "height": 1080 }}