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

Add page view events to WooCommerce Checkout flow. #34421

Conversation

senadir
Copy link
Contributor

@senadir senadir commented Dec 1, 2023

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:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • On a live, Jetpack connected website, install WooCommerce. It would be good to install WooCommerce Blocks from this link to avoid duplicate events.
  • Using a block theme and running Checkout Block and Cart Block.
  • Open Tracks Vigilante
  • View a product page, add it to cart, and visit Cart page and then Checkout.
  • Make sure the product_view and cart_view events fire.
  • Make sure all data is present, checkout_view should be similar to product_checkout.
  • Place the order, make sure the order_view event fire, it should be similar to product_purchase (with main different being that products is an array).
  • Do the flow again, now with Cart shortcode and Checkout shortcode.
  • The same events should fire with the same data.
  • Do the flow again but in a classic theme.

Copy link
Contributor

github-actions bot commented Dec 1, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/page-view-events-for-wc-checkout-flow branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/page-view-events-for-wc-checkout-flow
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] WooCommerce Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Dec 1, 2023
Copy link
Contributor

github-actions bot commented Dec 1, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for December 5, 2023 (scheduled code freeze on November 28, 2023).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Dec 1, 2023
@senadir senadir requested a review from opr December 1, 2023 16:39
Copy link
Contributor

@opr opr left a 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(),
Copy link
Contributor

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

$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.

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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

Copy link
Contributor Author

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.

@nielslange nielslange self-requested a review December 4, 2023 11:29
Copy link
Member

@nielslange nielslange left a 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 and woocommerceanalytics_product_checkout
  • woocommerceanalytics_order_confirmation_view and woocommerceanalytics_product_purchase

Copy link
Member

@nielslange nielslange left a 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.

@nielslange nielslange self-requested a review December 4, 2023 13:39
Copy link
Member

@nielslange nielslange left a 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. 🙌

senadir and others added 2 commits December 4, 2023 15:23
@senadir senadir merged commit bd36bf8 into update/classic-theme-tracking Dec 4, 2023
46 of 48 checks passed
@senadir senadir deleted the add/page-view-events-for-wc-checkout-flow branch December 4, 2023 14:51
@github-actions github-actions bot removed [Status] Needs Team Review [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] WooCommerce Analytics [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants