feat(analytics): "My Account" dashboard interactions#3949
Conversation
There was a problem hiding this comment.
@miguelpeixe I really like the abstractions you've put in place like registerElementActivity, registerCheckoutActivity, and registerActivityEvent which should make the Reader Data API even more robust and extensible. Thanks for making these changes.
Feedback is inline. I think you mentioned that we should do a review of the event params we want to collect in a separate PR, so I marked a couple of my items as non-blocking.
|
Also, I neglected to include this interaction in the original proposal, but should we add an activity/event for updating account details? |
That sounds like a solid idea to me, and this could help us cover other form submissions throughout My Account even if we don't write custom events for them. |
… edit_account form
|
Switched the address update strategy to use Also updated the PR description |
dkoo
left a comment
There was a problem hiding this comment.
@miguelpeixe this is working great, and the use of form_submit to capture edit account and address updates is an excellent idea. A couple of minor things I saw and one thing that I think we need to refactor (below, inline).
- Not sure if this is related to this changeset, but when submitting updates to Edit Account and Address forms, I see a PHP warning:
PHP Warning: Undefined variable $field_values in /var/www/html/wp-content/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFieldsFrontend.php on line 312. This doesn't seem to affect anything functionally, AFAICT. - Renewing an active subscription from the My Account > My Subscription page fires the same
np_product_reorderedevent as if clicking "Order again" on a past order from the "Orders" page. Should we consider a separate event for subscription renewals, or is it okay to conflate these two actions?
This seems unrelated to this PR and I'm unable to reproduce (on either trunk or this branch). I think this should be looked at separately.
Oh, that's unexpected. Great find! I guess we can track that as well then 😄 |
There was a problem hiding this comment.
This seems unrelated to this PR and I'm unable to reproduce (on either trunk or this branch). I think this should be looked at separately.
👍
Added the
subscription_renewal_earlyactivity/event containing thesubscription_idin 21306c8
Really close now! I'm seeing multiple instances of the np_subscription_renewal_early event when I click "Renew now", load the checkout page with the early renewal, and then finally complete the renewal. I think we should maybe fire only one event when you click the button to complete the renewal transaction, right?
|
Hm... that's strange, it should be the case because it's implemented via |
|
I'm unable to reproduce the issue. There's no activity attached to the "Renew Now" button, only the checkout. Can you log something at the |
dkoo
left a comment
There was a problem hiding this comment.
@miguelpeixe I think I see what's happening. If passing element as a string to registerElementActivity(), element becomes an array due to the querySelectorAll, but then the condition for defining the event to listen for assumes element is a single item. What's happening for me is that event is being redefined as click, so every time I click on an input inside the form[name="checkout"] element, it's firing the checkout activity. I think the suggested changes should solve this.
dkoo
left a comment
There was a problem hiding this comment.
Looking good, now! Thanks for the changes!
|
Hey @miguelpeixe, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [6.7.0-alpha.1](v6.6.2...v6.7.0-alpha.1) (2025-05-23) ### Bug Fixes * **404-images:** use JS without modifying content ([#3963](#3963)) ([9f5646b](9f5646b)) * add missing namespace ([#3980](#3980)) ([6d58793](6d58793)) * **emails:** add missing HTML markup in the change-email-cancel template ([#3981](#3981)) ([040ae30](040ae30)) * **ga4:** fire login/registration activities via SSO ([#3965](#3965)) ([8c97515](8c97515)) * hide modal content gate when modal checkout is opened ([#3953](#3953)) ([a503973](a503973)) * **jetpack:** handle the related posts max age option ([#3964](#3964)) ([8aad2b8](8aad2b8)) * make sure fix duplcate fields apply filters ([#3971](#3971)) ([f361a4e](f361a4e)) * namespace Lite Site ([#3975](#3975)) ([e4665ae](e4665ae)) * sync correction status with parent post status ([#3978](#3978)) ([dcd5a12](dcd5a12)) ### Features * add compatibility to network in custom bylines ([#3972](#3972)) ([199a993](199a993)) * add icons repository and remove custom icons ([#3883](#3883)) ([e56d2e0](e56d2e0)) * **analytics:** "My Account" dashboard interactions ([#3949](#3949)) ([22e9590](22e9590)) * **donations:** update notice style and type ([#3962](#3962)) ([3f60ef3](3f60ef3)) * **email-change:** remove env constant requirement ([#3943](#3943)) ([4158bf1](4158bf1)) * **my-account:** apply Newspack UI styles to My Account w/ env constant ([#3951](#3951)) ([e4aa5a2](e4aa5a2)) * **my-account:** full-site takeover template and custom nav menu ([#3974](#3974)) ([5cf8403](5cf8403)) * **woocommerce:** log error notices ([#3952](#3952)) ([1654007](1654007))
|
🎉 This PR is included in version 6.7.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.7.0](v6.6.4...v6.7.0) (2025-06-02) ### Bug Fixes * **404-images:** use JS without modifying content ([#3963](#3963)) ([9f5646b](9f5646b)) * add missing namespace ([#3980](#3980)) ([6d58793](6d58793)) * **emails:** add missing HTML markup in the change-email-cancel template ([#3981](#3981)) ([040ae30](040ae30)) * **ga4:** fire login/registration activities via SSO ([#3965](#3965)) ([8c97515](8c97515)) * hide modal content gate when modal checkout is opened ([#3953](#3953)) ([a503973](a503973)) * **jetpack:** handle the related posts max age option ([#3964](#3964)) ([8aad2b8](8aad2b8)) * make sure fix duplcate fields apply filters ([#3971](#3971)) ([f361a4e](f361a4e)) * namespace Lite Site ([#3975](#3975)) ([e4665ae](e4665ae)) * prevent auto-publishing corrections when scheduling posts ([#4006](#4006)) ([7531832](7531832)) * sync correction status with parent post status ([#3978](#3978)) ([dcd5a12](dcd5a12)) ### Features * add compatibility to network in custom bylines ([#3972](#3972)) ([199a993](199a993)) * add icons repository and remove custom icons ([#3883](#3883)) ([e56d2e0](e56d2e0)) * **analytics:** "My Account" dashboard interactions ([#3949](#3949)) ([22e9590](22e9590)) * **donations:** update notice style and type ([#3962](#3962)) ([3f60ef3](3f60ef3)) * **email-change:** remove env constant requirement ([#3943](#3943)) ([4158bf1](4158bf1)) * **my-account:** apply Newspack UI styles to My Account w/ env constant ([#3951](#3951)) ([e4aa5a2](e4aa5a2)) * **my-account:** full-site takeover template and custom nav menu ([#3974](#3974)) ([5cf8403](5cf8403)) * **woocommerce:** log error notices ([#3952](#3952)) ([1654007](1654007))
|
🎉 This PR is included in version 6.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

All Submissions:
Changes proposed in this Pull Request:
Dispatch reader data activities and GA4 events on My Account interactions:
subscription_cancelledsubscription_idsubscription_reactivatedsubscription_idsubscription_switchedpayment_method_deletedpayment_method_addedpayment_method: the method gateway (stripe, woocommerce_payments, etc)payment_method_changedsubscription_id,update_all_subscriptions*address_updatedaddress_type: EitherbillingorshippingSubmit an address update via the "Addresses" pageproduct_reorderedThe GA event for each activity above is
np_{activity}Update*: The
address_updatedwas removed in favor of GA's nativeform_submit. For accuracy, theform_nameshould bebilling_address,shipping_address, andedit_account.This PR also refactors the analytics approach to introduce a few utility functions and reduce repetition.
How to test the changes in this Pull Request:
reader_registeredandreader_logged_inevents continue to work as proposed in fix(analytics): migrate back-end GA4 events to front-end #3895Other information: