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.72k stars 2.63k forks source link

Segment causes inconsistent average time on page #4719

Closed anonymous-matomo-user closed 8 months ago

anonymous-matomo-user commented 10 years ago

There seems to be an issue, when I create a segment so that only the page-titles of pages that contain a certain string inside the URL (for example pageUrl="/cms/" ) are displayed: The segment works, but it seems to affect the "avg. time on page" values in a strange way. For example: A certain Page shows without segment about 22min time on page and with segment it show about 46 seconds (see screenshots). All the other metics seem to be identical, though.

anonymous-matomo-user commented 10 years ago

Attachment: Page Title with Segment selected (and different usage time) page_titles_with_segment.png

anonymous-matomo-user commented 10 years ago

Attachment: Page Title without Segment selected page_titles_without_segment.png

anonymous-matomo-user commented 10 years ago

Attachment: Page Title with Segment selected (and different usage time) page_titles_with_segment.2.png

anonymous-matomo-user commented 10 years ago

Attachment: Correction: Page Title with Segment selected (and different usage time) page_titles_without_segment.2.png

apawell commented 10 years ago

I believe we are seeing a different manifestation of the same problem. piwik-dsg-segment piwik-all-visits-dsg

We want to take advantage of the segmentation feature to send each segments' content manager a monthly report email (html, not pdf) via the built-in reporting tab that has only "Actions: Page titles" chosen. We noticed that the avg. time on page that we saw drilling down from the default "All visits" segment did not match the avg. time spent in our reports for any specified segment, even though the other stats matched. I am able to see the avg. time mismatch between "All visits" and any chosen segment in the Piwik interface as well, so it doesn't look like it's a problem with generating the report.

For an example, I have attached two screen shots that I think should be reporting the same information. The file piwik-dsg-segment shows our segment DSG (defined by Page URL here) had an avg. time on page of 20s. In the file piwik-all-visits-dsg, the DSG Home Page statistics match DSG segment's - with the exception that the avg. time on page is reported as 2min 29s.

I have re-read the documentation on how to set up segments and tried using various definitions for the segment, but I cannot get the avg. time for a segment to match the avg time that is reported by drilling down from "All visits" under Actions: Page titles. [The stats for my various segment definitions did match each other though!] If I'm missing something, please let me know.

Bug #4719 was apparently opened per Stefan's question above and is now a low priority. I have two questions:

  1. Is there any chance this can be fixed in the next month or two?
  2. Is there any work around?

Thank you for any assistance you can give me.

Cheers, Amy

mattab commented 9 years ago

I looked into this but unfortunately I'm not sure the correct way we could solve this bug.

The SQL Query with segment on page url looks like:

            SELECT
                log_link_visit_action.idaction_url_ref as idaction, log_action.type, log_action.name, count(*) as `12`,
                sum(log_link_visit_action.time_spent_ref_action) as `13`
            FROM
                piwik_log_link_visit_action AS log_link_visit_action
                LEFT JOIN piwik_log_action AS log_action ON log_link_visit_action.%s = log_action.idaction
            WHERE
                ( log_link_visit_action.server_time >= ?
                AND log_link_visit_action.server_time <= ?
                AND log_link_visit_action.idsite = ?
                AND log_link_visit_action.time_spent_ref_action > 0
                AND log_link_visit_action.%s > 0 AND log_link_visit_action.idaction_event_category IS NULL )
                AND
                ( ( log_link_visit_action.idaction_url IN (SELECT idaction FROM piwik_log_action WHERE ( name LIKE CONCAT('%', ?, '%')  AND type = 1 )) ) )
            GROUP BY
                log_link_visit_action.%s, idaction
            ORDER BY
                `12` DESC, log_action.name ASC"

The problem is that the segment on Page URL is applied to this query (( ( log_link_visit_action.idaction_url IN (SELECT idaction FROM piwik_log_action WHERE ( name LIKE CONCAT('%', ?, '%') AND type = 1 )) ) )) which restricts the rows that we query. As a result, I believe that only Pages which were redirected to this page are counted in the "Average time on page".

Fix? when we process the average time on page in the Actions Archiver, maybe we could skip and do not apply the Page URL segment - in function archiveDayActionsTime

mattab commented 8 months ago

Thanks for contributing to this issue. As it has been a few months since the last activity and we believe this is likely not an issue anymore, we will now close this. If that's not the case, please do feel free to either reopen this issue or open a new one. We will gladly take a look again!

atom-box commented 4 months ago

There might have been a regression. Average time on page, for a segment, seems broken in Matomo 5. See the user's comment and screenshots here:

"Why is the "average time on page" different for a Page URL for "All Visits" and for a segment where only the action URL is filtered? Surely that should be the same?"

All Visits: image

Same URL but as a Segment image image

atom-box commented 3 months ago

I cannot reproduce this issue.

Matomo Cloud seems fine:

image

PeteTrombone commented 3 months ago

We have the problem with the segments.

sgiehl commented 3 months ago

@PeteTrombone are you already using Matomo 5?

PeteTrombone commented 3 months ago

@sgiehl yes, 5.0.3

sgiehl commented 3 months ago

@PeteTrombone Does it happen for all type of segments or only specific segments - like segments on action or visit dimensions only.

PeteTrombone commented 3 months ago

@sgiehl it is as atom-box described. We only noticed it in segments with the "Action URL".