I need help for writing custom javascript in data layer. I am trying to get names.
promotionImpression:
{
event: 'promoImp',
ecommerce: {
promoView: {
promotions: {
142398:{
id: '142398',
name: 'sadr'
},
142312:{
id: '142312',
name: 'qas'
}
}
}
} },gtm.uniqueEventId: 470
I have tried this javascript but it returns undefined. When I tried this locally it returns names perfectly.
function() {
var names = [];
for (promotion in ecommerce.promoView.promotions) {
names.push(ecommerce.promoView.promotions[promotion].name);
}
return names.join(); }
Can anybody help on this. Thanks in advance.