I'm trying to implement product impressions (https://developers.google.com/tag-manager/enhanced-ecommerce#product-impressions) on an ecommerce catalog page using Universal Analytics. The problem i'm having is of practical nature, where I want to push one event containing every impression-object rather than an event for each catalogue product being displayed, but that is not the case as can be seen here:
Each product being displayed in the catalogue list ends up becoming an impressions-object by itself in the dataLayer, rather than having one impressions-object with all the information (such as Google's own example). Is there a way of nesting each productImpressions event into one, and then pushing that one object containing all catalogue-page results? This is the code I have implemented at the moment which does the pushing to the dataLayer:
// Product View, triggered when product is viewed on any page:
function googleTagManagerProductViewDataLayerPush(productName, productSKU, productPrice,
productBrand, productCategory, productVariant, productList, positionInList, regularProductPrice) {
dataLayer.push({
'event': 'productImpressions',
'ecommerce': {
'currencyCode': 'SEK',
'impressions': [{
'name': productName,
'id': productSKU,
'price': productPrice,
'brand': productBrand,
'category': productCategory,
'variant': productVariant,
'list': productList,
'position': positionInList,
'metric1': regularProductPrice
},
{
'name': productName,
'id': productSKU,
'price': productPrice,
'brand': productBrand,
'category': productCategory,
'variant': productVariant,
'list': productList,
'position': positionInList,
'metric1': regularProductPrice
}]
}
});
}
I call this function for each product/item on my product catalogue, for instance search results. I'm thinking I could send in arrays but that wouldn't dynamically create objects of each product being displayed nested within one productImpressions event, which I would like.
Does anyone have ideas on how to solve this?