• Resolved akosbekens

    (@akosbekens)


    Hi there,

    Thanks for the much needed backend implementation.

    However I have one issue to report and one ‘feature request’.

    I’ve been running the plugin alongside the client GA and the ecommerce tracking is much more accurate but in GA the transaction details show that the prices are being sent the wrong way.

    It has to be unit prices, not subtotals since GA multiplies the given price with the quantity.

    Also most of the time the WP id for the product is not very helpful if one tries to create reports so I added the functionality to have the SKU as an id:

    Here’s the part of class_nsc_gabt_collect_data_order.php:97 I modified so the prices are correct and the SKU is used if it exists:

    $product = new WC_Product($orderItem->get_product_id());
    
    $productPriceWithTaxes = $orderItem->get_subtotal() + $orderItem->get_subtotal_tax();
    $productPriceWithTaxes = $productPriceWithTaxes / $orderItem->get_quantity();
    $productPriceWithTaxes = $this->format_number($productPriceWithTaxes);
    
    $sku = product->get_sku();
    
    $ga_order_items[$productIndex]["id"] = (!empty($sku)) ? $sku : $orderItem->get_product_id();
    $ga_order_items[$productIndex]["name"] = $orderItem->get_name();
    $ga_order_items[$productIndex]["qty"] = $orderItem->get_quantity();
    $ga_order_items[$productIndex]["productPriceWithTaxes"] = $productPriceWithTaxes;
    $ga_order_items[$productIndex]["variation_id"] = $orderItem->get_variation_id();
    $ga_order_items[$productIndex]["categories"] = strip_tags(wc_get_product_category_list($orderItem->get_product_id()));
    $ga_order_items[$productIndex]["tags"] = strip_tags(wc_get_product_tag_list($orderItem->get_product_id()));
    $productIndex = $productIndex + 1;

    Please consider updating the plugin.

    Thanks,
    ákos

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Support

    (@nikelschubert)

    Hi @akosbekens,
    happy to hear that you like the plugin.
    Thanks a lot for your feedback and your code examples.
    I just released a new version 2.2 with the changes.

    Regards

    Thread Starter akosbekens

    (@akosbekens)

    Thanks a lot.

    Have a nice day. ??

    Thread Starter akosbekens

    (@akosbekens)

    Hey @nikelschubert,

    Last Friday I updated the plugin and no e-commerce purchase events have been sent since.

    Could you please take a look at it?

    BTW: the JS console tracking outputs this (but no data in the GA account):

    cid: "1611156614.686588828"
    dl: "https://***/penztar/order-received/19402/?key=wc_order_***"
    dr: "https://***/penztar/"
    ds: "wp-backend-tracking"
    pa: "purchase"
    pr1ca: "Egyéb"
    pr1id: "8001010"
    pr1nm: "Prod 1"
    pr1pr: "10990.00"
    pr2ca: "Egyéb"
    pr2id: "8001020"
    pr2nm: "Prod 2"
    pr2pr: "9990.00"
    t: "pageview"
    tcc: "0"
    tid: "UA-***"
    tr: "20980.00"
    ts: "0.00"
    tt: "0.00"
    ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36"
    uip: "***"
    v: "1"

    Thanks,
    ákos

    Plugin Author Support

    (@nikelschubert)

    @akosbekens
    Hi, i am really sorry that you have problems with the transactions now. And thanks a lot for your report.
    I just released a new version: 2.3.1 hopefully this should be fixed then. In 2.2 I introduced for security reasons a filter which was a bit too aggressive.

    Regards

    Thread Starter akosbekens

    (@akosbekens)

    It works perfectly again.

    Thanks for the quick response.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wrong value for productPriceWithTaxes and SKU feautre’ is closed to new replies.