Closed phildpearce closed 10 years ago
This is a situation that is odd to handle. If the product is discounted (using Catalog Price Rules), you will see the correct total for the line item. However, if the order is discounted (using Shopping Cart Price Rules) as far as Magento is concerned the product itself was not discounted - it just subtracts the discount amount from the order total. This results in the scenario you describe, where the sum of the product totals is more than the transaction total.
Googling the subject, I can see that a lot of people in the GA community are not quite sure what to do about discounts, as the syntax of the transaction request does not accommodate it. There appears to be no word from Google on the subject either.
I would guess the important thing is that the overall revenue (based on the transaction total) is the important thing to get right, as this will be the top level figure used in most e-commerce reports.
Until such a time that there's an official answer on this, I'd be a bit reluctant to change the logic. At best, I might consider adding a line item for discount with a negative price value and using Magento's description of the specific discount for the product name, provided that this works. For example:
dataLayer = [{
// Most variables trimmed for brevity.
"transactionTotal":30,
"transactionProducts":[{
"name":"Bioshock Infinite",
"sku":"bio-3",
"category":"PC Games",
"price":35,
"quantity":1
},{
"name":"Discount: £5 off all games",
"sku":"discount",
"category":"Discount",
"price":-5,
"quantity":1
}]
}];
Understood that top level transactionReveue is uneffected, but affiliates such as CommissionJunction use the item level revenue to calculate the total. In this instance TOO MUCH commission is paid to the affiliate if a promo code is used.
Also, as you rightly state - GA product level revenue will not match GA transaction totals, which causes a data confidence issue, and raises awkward questions.
\ Please see the Qubit code that was used to patch this - can you copy their patch? https://github.com/QubitProducts/UniversalVariable-Magento-Extension/issues/35#issuecomment-39827995
Also, regarding your proposed solution of sending the same item name with a -£xx as a second addItem request. GA.js and Analytics.js prevent sending the same item twice, unless a _gaq.push(['_clearTrans']); is added inbetween. This issue appears on website App where there are multiplte £1 ingame top-up within the same visitor session.
About: clearTrans http://stackoverflow.com/questions/18700118/google-analytics-ecommerce-erroneously-re-submitting-previous-transactions-with https://plus.google.com/117298997433687198127/posts/JNqx7o3beoy
Hence fixing the itelm level dataLayer.transactionProducts.price (if transactionProducts.promoCode is not null) is needed.
Item level revenue (transactionProducts.price) is INCORRECT when a promoCode is applied. The full price is output not the discounted price at item level.
Note: top level TransactionTotal is correct.
Change transactionProducts.price to use "product" instead of "quote item" to fix.