• Resolved hungpham

    (@hungpham)


    When ordering one product with quantity > 1, the item price returns subtotal, that means it includes the price of one unit of the product multiplied by the quantity. It leads to wrong result in Google Analytics item revenue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @hungpham

    Thanks for reaching out!

    I understand that you’re facing an issue where the item price, when multiplied by quantity, is being reflected as the subtotal in Google Analytics, thus resulting in inaccurate revenue reporting.

    Could you please provide us with a clear screenshot of what you’re seeing on your end? This will help us better understand your situation and address your concerns more effectively.

    If you don’t already have a screenshot service installed, you can try https://snipboard.io. You can share the direct link to the image as a response to this topic.

    Furthermore, I’d like to understand your site properly. Please share with us the necessary information below for us to investigate the issue further:

    • System Status Report which you can find via WooCommerce > Status > Get system report > Copy for support.
    • Fatal error logs (if any) under WooCommerce > Status > Logs.

    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Once we have more information, we’ll be able to assist you further.

    Thread Starter hungpham

    (@hungpham)

    There is no error. And your code is clearly using subtotal, which is the revenue already. That’s why the item price in purchase event is incorrectly. Here is the code I copy from src/Google/GoogleiteTag.php

    foreach ( $order->get_items() as $item_id => $item ) {
    $product_id = $item->get_product_id();
    $product_name = $item->get_name();
    $quantity = $item->get_quantity();
    $price = $item->get_subtotal();
    $item_info [] = sprintf(
    ‘{
    id: “gla_%s”,
    price: %f,
    google_business_vertical: “retail”,
    name: “%s”,
    quantity: %d,
    }’,
    esc_js( $product_id ),
    $price,
    esc_js( $product_name ),
    $quantity,
    );
    }

    Can you check with your developer why they use get_subtotal() function there?

    Hi there @hungpham ??

    From what I gather, you are referring to lines 301 to 319 (linked here), of the GlobalSiteTag.php file. Correct?

    Feel free to submit an issue on GitHub, via this link, with the steps to reproduce your finding.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[bug] item price is not correct’ is closed to new replies.