Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker: Delay log of page view/visit to include onload metric #20735

Open
wants to merge 2 commits into
base: 5.x-dev
Choose a base branch
from

Conversation

rr-it
Copy link
Contributor

@rr-it rr-it commented May 16, 2023

Description:

This PR delays logging of every page view/visit to whatever comes first:

  • after load event is fired
  • visitor leaves page

The PagePerformance metric time_on_load is only availible via JavaScript API PerformanceTiming.loadEventEnd in the browser after the load event handler has finished.

Related to #20726

Review

@rr-it rr-it force-pushed the issue/20726-tracker-performance-metric-onload branch 2 times, most recently from 7414fe1 to c5cbf4d Compare May 16, 2023 19:40
@rr-it rr-it changed the title [WIP][!!!] Tracker: Delay log of page view/visit to include onload metric [WIP] Tracker: Delay log of page view/visit to include onload metric May 16, 2023
@rr-it rr-it changed the title [WIP] Tracker: Delay log of page view/visit to include onload metric Tracker: Delay log of page view/visit to include onload metric May 30, 2023
@rr-it
Copy link
Contributor Author

rr-it commented May 30, 2023

For me this works as expected in production now. Especially when the Matomo tracking code is executed before onload.

Without this change implemented (day A):
Some data for dom_completion and on_load is missing.

views total network server time_transfer processing dom_completion on_load
with peformance data 3925 3925 3925 3925 3739 1577 < 1577 <
without peformance data 1688 0 0 0 0 0 0
SQL to reproduce statistics (click to open)

Hint: COUNT() does not take values of NULL into account.

SELECT
'with peformance data' as views,
COUNT(`idlink_va`) as total,
COUNT(`time_network`) as network,
COUNT(`time_server`) as server,
COUNT(`time_transfer`) as time_transfer,
COUNT(`time_dom_processing`) as processing,
COUNT(`time_dom_completion`) as dom_completion,
COUNT(`time_on_load`) as on_load
FROM `matomo_log_link_visit_action`
WHERE `idsite` = 1
AND `time_server` > 0 AND `time_server` IS NOT NULL
AND server_time > '2023-05-28 12:30:00' AND server_time < '2023-05-29 12:30:00'

UNION

SELECT
'without peformance data' as views,
COUNT(`idlink_va`) as total,
COUNT(`time_network`) as network,
0 as server,
COUNT(`time_transfer`) as time_transfer,
COUNT(`time_dom_processing`) as processing,
COUNT(`time_dom_completion`) as dom_completion,
COUNT(`time_on_load`) as on_load
FROM `matomo_log_link_visit_action`
WHERE `idsite` = 1
AND `time_server` IS NULL
AND server_time > '2023-05-28 12:30:00' AND server_time < '2023-05-29 12:30:00'

With this change implemented (day B):
Nearly every record with performance data has also tracked dom_completion and on_load.

views total network server time_transfer processing dom_completion on_load
with peformance data 3977 3977 3977 3976 3976 3898 < 3895 <
without peformance data 1715 0 0 0 0 0 0
SQL to reproduce statistics (click to open)

Hint: COUNT() does not take values of NULL into account.

SELECT
'with peformance data' as views,
COUNT(`idlink_va`) as total,
COUNT(`time_network`) as network,
COUNT(`time_server`) as server,
COUNT(`time_transfer`) as time_transfer,
COUNT(`time_dom_processing`) as processing,
COUNT(`time_dom_completion`) as dom_completion,
COUNT(`time_on_load`) as on_load
FROM `matomo_log_link_visit_action`
WHERE `idsite` = 1
AND `time_server` > 0 AND `time_server` IS NOT NULL
AND server_time > '2023-05-29 12:45:00'

UNION

SELECT
'without peformance data' as views,
COUNT(`idlink_va`) as total,
COUNT(`time_network`) as network,
0 as server,
COUNT(`time_transfer`) as time_transfer,
COUNT(`time_dom_processing`) as processing,
COUNT(`time_dom_completion`) as dom_completion,
COUNT(`time_on_load`) as on_load
FROM `matomo_log_link_visit_action`
WHERE `idsite` = 1
AND `time_server` IS NULL
AND server_time > '2023-05-29 12:45:00'

@rr-it rr-it marked this pull request as ready for review May 30, 2023 09:01
@rr-it rr-it force-pushed the issue/20726-tracker-performance-metric-onload branch from c5cbf4d to c926fb7 Compare May 30, 2023 13:17
@rr-it rr-it force-pushed the issue/20726-tracker-performance-metric-onload branch from c926fb7 to 4cec8c7 Compare June 1, 2023 13:23
@github-actions
Copy link
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Jun 16, 2023
@github-actions
Copy link
Contributor

This PR was last updated more than one month ago, maybe it's time to close it. Please check if there is anything we still can do or close this PR. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale for long The label used by the Close Stale Issues action label Jul 29, 2023
@github-actions github-actions bot removed Stale for long The label used by the Close Stale Issues action Stale The label used by the Close Stale Issues action labels Jan 31, 2024
Copy link
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Feb 15, 2024
Copy link
Contributor

This PR was last updated more than one month ago, maybe it's time to close it. Please check if there is anything we still can do or close this PR. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale for long The label used by the Close Stale Issues action label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale for long The label used by the Close Stale Issues action Stale The label used by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant