-
Notifications
You must be signed in to change notification settings - Fork 804
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
Add page view events to WooCommerce Checkout flow. #34421
Add page view events to WooCommerce Checkout flow. #34421
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested and the page view events themselves seem to be tracking well across shortcode/classic shortcode/blocks in both classic and block themes 🥳
There's just a couple of things I spotted that I mentioned inline, but not sure if it makes total sense to fix them here given the wider scope of these changes. I think we should ensure the tracking events are working in this PR (which they are), merge it into update/classic-theme-tracking
then address any code-cleanup (i.e. what I left in the inline comments) in that PR? What do you think?
'guest_checkout' => $guest_checkout, | ||
'express_checkout' => 'null', // TODO: not solved yet. | ||
'number_products' => $cart->get_cart_contents_count(), | ||
'order_value' => $cart->get_cart_contents_total(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be copied from
Lines 230 to 233 in 479c0d0
$order_value = '0'; | |
if ( isset( $order_totals['total'] ) ) { | |
$order_value = $order_totals['total']; | |
} |
The current code in this event looks like it's only the subtotal, and not in the same format as the "core" events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed differently, using get_cart_total
which saves us the formatting step.
* Jetpack_WooCommerce_Analytics_Checkout_Flow constructor. | ||
*/ | ||
public function __construct() { | ||
$this->find_cart_checkout_content_sources(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot why you said this is necessary, the one that runs in the construct of Jetpack_WooCommerce_Analytics_Universal
isn't always running? Same for two lines below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall yet, I think the plugins where coming out without data
/** | ||
* Get Cart/Checkout page view shared data | ||
*/ | ||
protected function get_cart_checkout_shared_data() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this be in the trait? There are a few events in Jetpack_WooCommerce_Analytics_Universal
that would benefit from this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I just didn't want to touch the core events data much, but I'm likely to merge everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, @senadir. I mentioned a few minor inconsistencies between:
woocommerceanalytics_checkout_view
andwoocommerceanalytics_product_checkout
woocommerceanalytics_order_confirmation_view
andwoocommerceanalytics_product_purchase
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Show resolved
Hide resolved
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Show resolved
Hide resolved
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Outdated
Show resolved
Hide resolved
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a few more suggestions. Nothing critical, though.
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Show resolved
Hide resolved
.../modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-checkout-flow.php
Show resolved
Hide resolved
.../jetpack/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-trait.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the suggestions, I mentioned before, the PR works as expected. Thanks again for working on this, @senadir. 🙌
…/class-jetpack-woocommerce-analytics-trait.php Co-authored-by: Niels Lange <[email protected]>
NOTE: This should be merged until woocommerce/woocommerce-blocks#12010 is merged and assigned a version, since we will use that version to gate keep the work here.
This is part of our work here woocommerce/woocommerce-blocks#12010 to move page view events from WooCommerce Blocks to Jetpack, this ensures all shopper events live together and also now support classic cart/checkout views.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: