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

The quantity in the checkout event tracking is misplaced as index value #342

Closed
eason9487 opened this issue Dec 26, 2023 · 0 comments · Fixed by #343
Closed

The quantity in the checkout event tracking is misplaced as index value #342

eason9487 opened this issue Dec 26, 2023 · 0 comments · Fixed by #343
Assignees
Labels
type: bug The issue/PR is a confirmed bug.

Comments

@eason9487
Copy link
Member

Describe the bug:

Found this issue while working on #341.

In trackCheckoutStep function, it maps the cartItems array to getProductFieldObject.

export const trackCheckoutStep =
( step ) =>
( { storeCart } ) => {
if ( currentStep === step ) {
return;
}
trackEvent( step === 0 ? 'begin_checkout' : 'checkout_progress', {
items: storeCart.cartItems.map( getProductFieldObject ),
coupon: storeCart.cartCoupons[ 0 ]?.code || '',

However, the second parameter of getProductFieldObject is used as the quantity tracking property rather than the array index.

export const getProductFieldObject = ( product, quantity ) => {
return {
id: getProductId( product ),
name: product.name,
quantity,
category: getProductCategory( product ),

This leads to `quantity' being incorrect.

1

Steps to reproduce:

  1. Install and enable Google Analytics Debugger.
  2. Edit the checkout page to use the Checkout block.
    image
  3. Open the Console tab in the browser's DevTool.
  4. Add items to your cart and go to the Checkout page.
  5. Edit the email of the contact information.
  6. Inspect the checkout_progress event tracking via the Console tab.

Expected behavior:

The quantity in the event tracking should be the same as each product in the cart.

Actual behavior:

The quantity in the event tracking is the array index value of the products in the cart.

@eason9487 eason9487 self-assigned this Dec 26, 2023
@eason9487 eason9487 added the type: bug The issue/PR is a confirmed bug. label Dec 26, 2023
@eason9487 eason9487 changed the title The quantity in the cart event tracking is misplaced as index value The quantity in the checkout event tracking is misplaced as index value Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug The issue/PR is a confirmed bug.
Projects
None yet
1 participant