Matomo Scroll Tracking: Setup with Tag Manager & Insightful Reporting

Management Summary

Scroll tracking shows how much of your content visitors actually read. GA4 automatically tracks scrolling on a webpage using the “Advanced Measurement” feature. In Matomo, however, you’re left in the dark. This guide shows you how to implement a custom JavaScript scroll tracker using the Matomo Tag Manager. It records the maximum scroll depth when the user leaves the page, summarizes the data into meaningful percentages (25%, 50%, 75%, 100%), and sends it to Matomo as an event with custom dimensions. This configuration enables an extremely precise analysis of user engagement, allowing you to effectively optimize the length of your content and the placement of ads.

To understand user behavior, it’s not enough to simply count page views. When you publish long-form content, articles, or landing pages, you need to know whether visitors are actually reading your text or leaving the page right after the hero section. That’s where scroll tracking comes in.

Although Matomo has built-in features, using a custom JavaScript solution via the Matomo Tag Manager (MTM) gives you detailed control over your data, prevents server overload since the code is triggered only once per page, and consolidates the data in a clear, organized way for reporting.

Step 1: The custom JavaScript

Instead of triggering an event every time a user scrolls a few pixels, the following script calculates the maximum scroll depth and only sends the data to the data layer when the user leaves the page (beforeunload event).

It calculates the percentage of the way through the document and organizes it into clear groups (0%, 25%, 50%, 75%, 100%). It also calculates the total height of the document to provide context for the page length.

This script is implemented using a custom HTML tag in Matomo Tag Manager that is triggered on a “Pageview”:



Step 2: Setting Up the Matomo Tag Manager

Step 3: Reports and Insights

Once this configuration is active, go to the Matomo dashboard.

Navigate to Behavior > Events. Using the scroll action, you can now take a detailed look at specific URLs (event name) and view the average scroll depth (event value).

Alternatively, you can navigate to your reports on custom dimensions. By analyzing Dimension 10 (scroll_percentage), you can quickly get an overview of how many sessions across your entire website have reached the 25%, 50%, 75%, or 100% mark. If you notice a significant drop-off between 25% and 50%, you’ll know exactly where your content is losing readers’ attention.

Conclusion

Implementing a custom scroll tracking script via the Matomo Tag Manager is a resource-efficient and highly effective way to measure visitor engagement with your content. Calculating the maximum scroll depth when a visitor leaves the page and aggregating the metrics ensures clean and meaningful data without overloading your Matomo server with unnecessary requests.

Are you ready to find out how visitors really interact with your website? Copy the script above, set up the Matomo Tag Manager configuration, and start optimizing your content based on actual reading behavior.

Relevant content

More about Analytics