Highlighted

How to set decimal formatting before passing values to coremetrics

Rookie Contributor
How to set Decimal format for udo (js) values captured. For example in shop action 5 tag unit price variable is being passed with different decimal formatting: unit_price: Array : 0:"17.0" 1: "19.99" 2: "30.0" 3: "30" However this should be These four items should be reporting as: unit_price: Array : 0:"17.00" 1: "19.99" 2: "30.00" 3: "30.00" is there a way to achieve this?
1 REPLY 1
Highlighted

How to set decimal formatting before passing values to coremetrics

Tealium Employee
Nitin, One way to achieve this is to add a javascript code extension to modify your unit price array values to make sure there are two decimal places. Assuming the UDO variable is unit_price (adjust the code to the correct variable name if needed), add this as a javascript code extension. Scope it to all tags and place it above the e-commerce extension in the UI and these values will be mapped for all tags using e-commerce. for (i=0; i < b['unit_price'].length; i++) { b['unit_price'][i] = parseFloat( b['unit_price'][i] ).toFixed(2); }