Setting custom dimension value for trackEcommerceOrder


I added custom dimensions in trackEcommerceOrder but purchase tracking no longer works :
(Google Tag Manager)

var subTotal = {{ecommerce.purchase.actionField.revenue}} - {{ecommerce.purchase.actionField.shipping}};

    "{{}}",                     // SKU
    "{{}}",               	// name
    "{{ecommerce.purchase.products.0.category}}",               // category
     {{ecommerce.purchase.products.0.price}},                 	// price
     parseFloat({{ecommerce.checkout.products.0.quantity}})   	// quantity

// custom
_paq.push(['setCustomDimensionValue', 7, '{{ecommerce.checkout.products.0.dimension9}}']); //custom-9
_paq.push(['setCustomDimensionValue', 8, '{{ecommerce.checkout.products.0.dimension10}}']); //custom-10
// track order
    "{{}}",            // ID
     {{ecommerce.purchase.actionField.revenue}},        // grand total (value + tax + discount + shipping)
     subTotal,        					// sub total (value + tax + discount)
    0,                                                  // tax
    {{ecommerce.purchase.actionField.shipping}},        // shipping
    0                                                   // discount

This method however seems to work for trackEcommerceCartUpdate and addEcommerceItem.



I would guess that this error has not only something to do with your custom dimensions but rather your attempt to access an undefined value and parse it to a float. There should be an error message in the console.

You are accessing {{ecommerce.checkout.products.0.quantity}} which will most likely be unset in a purchase. And even in a purchase it might be unset anyway and so you should use a fallback value. Try changing the line




and see if data appears in the debugger again.

The custom dimensions will be unset as well because you will need to access the purchase instead of a checkout object here, too (I guess). Looks like a copy & paste classic (?)