-
Notifications
You must be signed in to change notification settings - Fork 286
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
Implement parsing of reports for custom dimensions #7602
Comments
Hey @nfmohit, this AC is looking good. One detail I think would be useful to specify here is how the parsed value should be returned in the response. That is to say, I would imagine that we need to simply return the parsed value in the report in place of the dimension value returned by GA4 - trying to add a extra value to the report would result in an unexpected report shape. It would be good to be clear about that here in the AC though, just for the avoidance of doubt. |
Thank you for the kind review, @techanvil. I've updated the ACs to be more precise. Please let me know if this looks good. |
That's great, thanks @nfmohit! AC ✅ |
Hi @jimmymadon, thanks for drafting this IB. I have a few thoughts - one of which is really a broader AC/design level point.
|
Sounds fancy! I think the only issue this change would affect is #7600. |
@techanvil Thanks for the helpful IB review as always. Everything makes better sense. Back to you for another pass! |
Thanks @jimmymadon! This is looking good - one very minor detail, I had rather imagined that That aside - Nahid mentioned that this change would affect #7600, fortunately this is already assigned to you, so I guess this is one to bear in mind there. I would have thought it would affect #7607 as well though, which is in the EB. Actually while reading #7607 something else has occurred to me... I've realised it's possible for more than one category to have the same name (if it's created under a different parent category). So I'm not sure if we might be introducing a possible issue here by making the returned dimensions potentially non-unique... Do you know if this aspect has been considered? Cc @nfmohit |
@techanvil - Have updated the IB regarding the JSON stringification. As for the category ancestor naming, it is something we can do as a nice to have in the future as per this comment. |
Thanks @jimmymadon, that looks great, and it seems fair to tackle the issue of duplicates later as it shouldn't cause us a problem as things stand. IB ✅ |
QA Update:
|
@wpdarren Yes - the 6 and 7 IDs do exist on the News Key Metrics test site (I can verify this when I connect it locally). Because your WP database does not have actual categories for IDs 6 and 7, there is no category name found and we've currently decided to just pass through the original IDs themselves. |
Feature Description
The response of report requests containing certain custom dimensions should be additionally parsed:
googlesitekit_post_author
dimension will output the author’s user ID. Hence, its response should be parsed such that the author display name is reported.googlesitekit_post_categories
dimension will output the category IDs. Hence, its response should be parsed such that the category names are reported.For example, if Site Kit makes a report request with the
googlesitekit_post_author
custom dimension, GA4 would return a user ID, e.g. 1. When sending this response back to the Site Kit dashboard, the user ID should be replaced with the display name of the user with that ID.See relevant section in the design doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
newsKeyMetrics
feature flag is enabled:googlesitekit_post_author
custom dimension will output the author's user ID. This should be parsed in the Site Kit backend such that the display name is obtained from the user ID and that is sent to the client, i.e. the parsed value should be returned in the report replacing the original dimension value returned from GA4.googlesitekit_post_categories
custom dimension will output a comma-separated list of category IDs. This should be parsed in the Site Kit backend such that the category names are obtained from the IDs and a comma-separated list of the category names are sent to the client, i.e. the parsed value should be returned in the report replacing the original dimension value returned from GA4.Implementation Brief
includes/Modules/Analytics_4/Report/Response
:get_author_display_name()
: This method should take in a user_id and return the display name of that user. This can be obtained by using theget_userdata
WordPress function that can be used to access the detailedWP_User
object, and return thedisplay_name
property.get_category_names()
: This method should take in an array of category IDs and return an array of category names. This can be obtained by using theget_cat_name
WordPress function.parse_custom_dimensions()
. This method will take in the same parameter asResponse::parse_response()
's$response
(theGoogle_Service_AnalyticsData_RunReportResponse
object).$response['dimensionHeaders']
.name
's matchgooglesitekit_post_author
orgooglesitekit_post_categories
, then call the appropriate method created above.$response['dimensionValues']
.$response['dimensionValues']
converting their IDs to the display names that the above methods return.Category,1
andCategory,2
are single categories:'["Category,1","Category,2"]'
Response::parse_response()
method:parse_custom_dimensions()
method ensuring the$response
object is modified correctly.Test Coverage
tests/phpunit/integration/Modules/Analytics_4/ResponseTest.php
:test_parse_response
method.QA Brief
customEvent:googlesitekit_post_author
andcustomEvent:googlesitekit_post_categories
custom dimensions. You may usenews-key-metrics.instawp.xyz
. Ask @nfmohit or @jimmymadon to grant you access to this domain's GA4 account/property/web datastream. NOTE: If you are connecting a GA4 property which has a different domain to the one you are currently using, then ensure the "Custom Site URL" within the Tester Plugin is set to the domain associated with the GA4 property, i.e.news-key-metrics.instawp.xyz
in our case.screenPageViews
for the custom dimensions in the ACs. These requests will eventually be run in the plugin in Create “Top categories by pageviews” key metric widget tile #7607 and Create “Most popular authors by pageviews” key metric widget tile #7605.dimensionValues
withinrows
show display names where a display name is found, otherwise, the original ID is passed through for now.Changelog entry
The text was updated successfully, but these errors were encountered: