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.87k stars 2.65k forks source link

Time spent on page differs wildly from what Google Analytics reports #19663

Closed miiimooo closed 2 years ago

miiimooo commented 2 years ago

Comparing Matomo Analytics Time spent on page and GA Time spent on page averages, they differ wildly.

Matomo will often be below 1 minute, when GA is over 1 minute, some examples

Pageviews Unique Pageviews Bounce rate Average time on page 
1. 78,845       63,367                     46%            00:00:40
2. 28,467       25,418                     83%            00:00:14
3. 20,403       19,650                     58%            00:00:10
Page Views Unique Page Views Bounce Rate Avg.Time on Page
1. 48,787         39,599                      53.79%         00:01:21
2. 25,744         23,124                      87.44%         00:01:34
3. 17,365         16,735                      96.52%         00:02:54

Providing some more metrics to show that everything else looks pretty similar.

Is there any way I can help to debug this? I'm using Matomo tag manager with heartbeat enabled

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce (for Bugs)

1. 4.

Context

Your Environment

sgiehl commented 2 years ago

Hi @miiimooo Thanks for creating this issue. Unfortunately there isn't much we can do about that. As long as you can't give use detailed insights how Google Analytics is calculating their time on page, we are unable to say why those numbers differs. I can actually only refer you to our FAQ, that explains how we calculate the metric: https://matomo.org/faq/how-to/faq_21158/

miiimooo commented 2 years ago

@sgiehl apologies for continuing in this thread. But in case you can advise, looking around GA is or was suffering from the same problem, and people recommended using a heartbeat like approach. If I understand it right, then in both GA and Matomo, this is handled when the next hit happens. Which sounds simple at first, but then - thinking about it - must be quite complex. Because somehow Matomo must keep track of the user, either in the client or the browser to reliably send the previous hit to the server. Looking at the 2nd request, it includes a urlref parameter in the payload. I see there is also a pv_id which must be the client unique id. So the server must then look up that previous url and modify the stored request and set the correct visit duration. Is that how it works?

sgiehl commented 2 years ago

No. Afaik it's actually a way less complex in Matomo. Visitors are identified with unique visitor ids, that are sent with the tracking requests. All tracking requests with the same visitor id will be tracked into one visit, unless the last tracking request was more than 30 minutes ago, in that case a new visit will be started for the visitor. The time on page will be simply calculated based on the page views being tracked. So the time between two page views is actually the time on page for the first page view. The last page view by default doesn't have a time on page, unless some further tracking requests are sent, that update the end time of the visit.

miiimooo commented 2 years ago

This visitor id, is it stored somehow locally, it must be right? I'm asking since we have enabled "Disable cookies" in MTM. Could that maybe impact on the Time On Page functionality?

sgiehl commented 2 years ago

The visitorid is stored in the cookie if possible. So not using cookies might make the visitor recognition a bit less accurate, as the visitors are then being matches based on a config hash, that is build out of various browser details. If you have more questions around that topic, maybe try discussing/asking that on our forum. I actually don't have enough time to give detailed answers on github.

MatomoForumNotifications commented 2 years ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/0s-pageviews-even-though-heartbeat-time-is-enabled/38161/8