matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.81k stars 2.64k forks source link

[Bug] Matomo track page view on preload/prerender #22627

Open ronan-hello opened 3 weeks ago

ronan-hello commented 3 weeks ago

What happened?

When a developer configures the preload/prerender function on his website in order to optimize the loading time of his pages, Matomo is triggered and counts the page (even though the page has not yet been displayed on the user's screen).

What should happen?

Matomo should handle preloading and not save the page view when the page has a preload or prerender request header. Tested with GA4 (it differentiates between classic page view and pre-rendered page view and does not follow pre-rendered page view).

How can this be reproduced?

  1. Create a website with 3 pages
  2. Add Matomo on every page (as usual).
  3. On page 1 add a script to preload page 2 and 3
  4. Visit page 1 with your browser
  5. Discover that Matomo fired on every preloaded pages, (user only visited page 1).
  6. Move to page 2, Matomo will be triggered again (normal situation).

Then you have :

PS: To be sure that preload is active on your browser, you can view preloaded URLs within Chrome Dev Tools (Application > Speculative loads)

Thank you Ronan HELLO

Matomo version

5.1.2

PHP version

8.3

Server operating system

Debian

What browsers are you seeing the problem on?

Chrome

Computer operating system

Windows and Mac

Relevant log output

No response

Validations

ronan-hello commented 2 days ago

Here is the official preview feature of WordPress that allow support for this feature : https://wordpress.org/plugins/speculation-rules/ If WordPress include this feature in the next WP release, Matomo will crteate doublon for every pages. This is an important point for web performance.

Regards Ronan