Order Level Promotion

Anonymous
Anonymous

Hi 

I have a more generic  issue where the Product revenue(sum of products*qty) in GA is higher than the order revenue(subtotal+shipping+tax).Upon digging in found that order level discounts are not being applied to product revenue

My main priority isto divide the order revenue proportionately between the products at unit level and pass the discounted product revenue.Is there a standard way of doing this .I will be using javascript extension in tealium and not sure on how to divide this  to the exact proportions on unit product price

example

s.no  item      unitprice     qty   total

1       xx            50             4         200

2       xy            6                2         12

---------------------------------------------------

                                 subtotal:      212

             order-level discount:       25

                                      tax:         3

                              shipping:       20

                           revennue:        210

3 REPLIES 3

Order Level Promotion

Tealium Employee

Hi @Anonymous

Depending on how you actually want to go about doing this, you can override the values set by the E-Commerce Extension. So options include:

  1. An extension before to update the product_price array with the discounted value
  2. An extension after to update the order total. ( b._ctotal)

Regards,

Adrian

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.

Order Level Promotion

Anonymous
Anonymous
Hi Adrian

Thanks for the reply ,i had implemented this in the same way that you described but my concern is more of a logical question on how to split the $25 discount between the products in equal ratio to their unit price amount.

Order Level Promotion

Tealium Employee

@Anonymous

So the issue you have with JS is decimal places. As soon as you start dividing by odd numbers you'll get numbers like 9.659999999999998 which will then cause discrepancies further down.

If you wanted to apply to the product prices I would first set up a variable with the amount of discount to apply to each item:

var discountToApply = Math.trunc(discount / product_prices.length) ; 
var remainingDiscout = discount - (discountToApplyproduct_prices.length)

Then a for loop that would minus that amount from each product. After the loop, you will need to subtract the remaining discount from one of the product prices.

This will give you the discount unit price for each item.

Adrian

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Public