When I put dataLayer[1].ecommerce.checkout.products[0].metric2
in the console, it return the correct value.
However, when I try to extract the value from a Custom JavaScript variable ('Test') in Google Tag Manager, it returns undefined
when Google Tag Manager is in preview mode.
The JavaScript code:
function(){
var basketSize = dataLayer[1].ecommerce.checkout.products[0].metric2;
return basketSize;
}