-
Notifications
You must be signed in to change notification settings - Fork 295
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
Ensure that GA4 widgets display correctly with real data (notably that the graphs handle missing/zero rows). #6623
Comments
ACs here make sense to me, I don't think there's much more we can do here so this seems the best approach to take for now. We'll probably want to adjust/audit how we handle There was a lengthy discussion on Slack about this between @felixarntz, @eugene-manuilov, @techanvil, @aaemnnosttv, and myself (@tofumatt), so I don't think multiple AC reviewers are needed. ACs 👍🏻 |
I don't think that will be necessary because it's already based on non-zero data existing, otherwise it uses the property's age rather than only the presence of rows as with UA. |
Hey @nfmohit, this IB is looking good. I have a few points for your consideration:
|
Hey @tofumatt @nfmohit, while reviewing #6544 I've noticed that it has a requirement to use the First, I'll make a quick side note that we need to make sure we also update the returned With that taken care of it occurs to me that, as it stands, we are set to always populate rows for a requested date range, regardless even of when the property was created, and this in turns would make this check a bit useless as it would always return Not sure what the best answer here is - maybe we should keep track of the creation date for the current GA4 property and only populate rows for subsequent dates. Mind you it still makes the I guess it depends what we really want to achieve for #6544 - if we want the banner to only display when there are 3 days of real data, then it points to a requirement to make this zero-data padding optional for a request. Alternatively, maybe the logic there should be adjusted to check whether it's 3 days since the first real data was tracked for the property (this could be managed without making the padding optional as we'd just check for a non-zero value), something that might be viable particularly if we're doing the same sort of query for #6572 (comment). Bit of a tricky one. Interested to hear your thoughts! |
That seems reasonable, as we need to use the I think it'd be fine to display the banner once several days have gone by since the property has been created. That banner is shown to users who are already collecting Analytics data, so presumably they'll have visits, but if not they'll at least be able to cross-reference the zero data from both and see it's legitimate. And since they're using Site Kit they should be collecting data as we would have placed the GA4 tag for them, so we know it's working. |
I've updated the IB with your comments @techanvil, thanks! Regarding the empty row count vs creation date… I think creation date is the best way forward. Let me know what you think; I mentioned as much in #6544 as well. |
QA Update: ✅Verified:
Added |
QA ✅ from me, follow @techanvil's suggestion and used his code sample to test out some reports with gaps, the data appears padded as-expected 👍🏻 Moving to approval. |
Feature Description
At the time of writing, the GA4 API is not returning rows for days with no data when querying by the
date
dimension, even when thekeepEmptyRows
flag is set totrue
. This is true for other dimensions too, but all our graphs usedate
-indexed reports.As a result, presented with real data that has missing rows, the GA4 graphs will omit what should be a zero data point for each of those rows and draw a line that doesn't touch the bottom of the graph when it should.
We need to ensure these graphs plot correctly. Additionally, care must be taken to ensure that there are no other aspects of the widgets that are affected by this.
@aaemnnosttv is currently in communication with the Analytics team to clarify whether
keepEmptyRows
is working as intended and this could result in some change to the API which is currently in beta. As a result this can remain in Triage for now, with the AC to be completed once we know how the API will be working going forward.The likely resolution will be either:
isGatheringData()
selector which has so far worked around the new state of the API.GET:report
handler. This should be manageable if we keep the scope contained to the single-dimensiondate
case. Trying to support combinations of dimensions could make this considerably more complicated which is a bit of a warning for future proofing this solution, but it would have the advantage of being a centralised fix.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
analytics-4
handler forGET:report
on the server should be updated so that it always returns rows for the requested date range but only whendate
is the only requested dimension (i.e. simply includingdate
as a requested dimension along with one or more additional dimensions would not work)Implementation Brief
includes/Modules/Analytics_4.php
:GET:report
response, sayparse_report_response()
. It should do the following:$data
and$response
parameters.dimensions
array property in$data
has only one item, and if that item'sname
property isdate
.$response
.rows
array property and see if the rows are missing any dates. The logic for determining which dates are missing depends on whether or not thecompareStartDate
andcompareEndDate
request parameters are present.startDate
toendDate
should have an entry per day, with rows filled in for missing days.startDate
toendDate
, and the other being the range fromcompareStartDate
tocompareEndDate
. Any missing days fromstartDate
toendDate
should be filled in, and any missing days fromcompareStartDate
tocompareEndDate
should be filled in. If there's an overlap of the date ranges, only one row per day is required (there shouldn't be multiple rows for the same date).rows
in response and all the possible dates in the date ranges, a row array should be inserted for each missing date withdimensionValues
being a nested array property with thevalue
being the missing date (similar to other rows), andmetricValues
being another nested array property with thevalue
being'0'
. The number ofarray( 'value' => '0' )
entries in themetricValues
array should match the length of metrics being requested.rowCount
property should be updated to reflect the new number of rows.parse_data_response()
method, add a case to the switch for theGET:report
datapoint that calls the newparse_report_response()
method with$data
and$response
passed to it and returns it.Test Coverage
tests/phpunit/integration/Modules/Analytics_4Test.php
:get_report
test cases to reflect the above changes.QA Brief
Developer Tools
and select your request. It will open request details where you need to select the preview tab. It will show you response information. Make sure that you see there are the right number of rows with metric values all zero like on this screenshot:QA:Eng
See Tom's comment here and try to do what he suggests: #6790 (review)
Changelog entry
runReport
endpoint to add zero-data rows where data is missing in cases where a singledate
dimension is requested.The text was updated successfully, but these errors were encountered: